Issue Details (XML | Word | Printable)

Key: BATCH-568
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dave Syer
Reporter: Tan Khai Shen
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Spring Batch

Return Object[] if cursor.get() return Object array size > 0

Created: 08/Apr/08 03:35 AM   Updated: 07/Aug/08 10:07 AM
Component/s: Infrastructure
Affects Version/s: 1.0.0
Fix Version/s: 1.0.1

Time Tracking:
Original Estimate: 0.04d
Original Estimate - 0.04d
Remaining Estimate: 0.04d
Remaining Estimate - 0.04d
Time Spent: Not Specified
Remaining Estimate - 0.04d


 Description  « Hide
public Object read() {
if (!initialized) {
open(new ExecutionContext());
}
if (cursor.next()) {
currentProcessedRow++;
Object data = cursor.get(0);
return data;
}
return null;
}

If we use HQL with group by clause, it will return more than 1 column.

 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Dave Syer added a comment - 08/Apr/08 03:42 AM
This is the HibernateCursorItemReader right? Do you mean "if we use HQL with projection"? What happens if you do that (how is it broken)?

Tan Khai Shen added a comment - 08/Apr/08 03:52 AM
My HQL is:

select o.field1, o.field2, count(field1)
from PO o
and o.field1<> null
group by o.field1, o.field2

I want these 3 fields in my ItemWriter

So, instead of

Object data = cursor.get(0);
return data;

Can we change to:

Object[] datas = cursor.get();
if ( datas.length == 1){
return datas[0];
}
return datas;

So, in my ItemWriter:
public void write(Object data) throws Exception {
        Object[] results = (Object[])data;
        String field1 = (String)results[0];
        String field2 = (String)results[1];
        Integer field3 = (Integer)results[2];
}

What do you think?

Dave Syer added a comment - 08/Apr/08 06:41 AM
Makes sense. Fixed for 1.0.1.

Dave Syer added a comment - 07/Aug/08 10:07 AM
Assume closed as resolved and released