-
Mar 10th, 2009, 05:15 AM
#11
I think my biggest concern is this:
My Job will only ever run for 1 province, so there will always be only 1 RecordType1.
But there will always be 1 or more schools (RecordType2) and definitely more than 1 candidate per school, with his subjects.
The use case as we discussed will work if I separate my incoming resultset row into 4 different domain object types etc Province, School, Candidate, Subject.
Then I can pass each object type and the ClassifierLineAggregator would know which aggregator to use in order to write the record out to file because it will classify on domain object type.
Currently I only build 2 domain object types in my RowMapper, that is Candidate and his Subjects. The reason I am not creating the Province and School domain object type is because I'm not sure how to keep track of them across multiple calls to mapRow in the rowMapper.
That is for each row in the resultset there will be only 1 candidate and his subjects. but the province info and school info for the same school is returned on multiple rows .
So my question:
Lets say my resultset from the DB contains 10 rows.
All 10 rows contains info for the same Province.
The first 5 row are for 1 school and the last 5 for another.
How do I construct my School domain object? on the first call to mapRow I will create
1 Province object, 1 school object, 1 Candidate object and multiple Subject objects and link them to each other via simple relationships.
On the 2nd call to mapRow how do I now check that this Province and School actually already exists? I only want to create a new School object if it differs from the previous one created in the previous call to mapRow?
Can I keep an instance variable in my custom row mapper? Is that clean?
I will look into the multilineOrderJob sample again, but last time I had a look it didn't help me out with my province and school info which actually sits in my Candidate domain model?
Any further ideas? If you would like a complete description of my use case, please say so and I will post it.
-
Mar 10th, 2009, 05:26 AM
#12
You see, my biggest problem is not Candidate, because all the Candidate info along with all his Subjects are written to the same line in the File, this is RecordType3.
My concern is the RecordType1 (Province info) and RecordType2(School info) because I am firstly struggling to model them from my Rowmapper.
Maybe I should extend FlatFileItemWriter, pass in Candidate object and just manually do the logic in my writer, and call the write method on another Writer (A custom writer for ecah RecordType) manually according to my logic?
-
Mar 10th, 2009, 06:45 AM
#13
Just Remembered why I did not follow the multilineorder use case.
In my first step I have the Itemreader, and a compositeItemWriter consisting out of 5 Other writers. 1 of them is the FlatFileItemWriter.
If I use a processor as in the Sample the following happens:
in the process method an Order item is received and a List<String> collection is returned.
That is we have now lost our original Domain Object.
This is fine if you only have 1 Writer which expects it like that, but in my case the other Writers are still expecting the Domain Object and not the collection as returned by the processor?
-
Mar 10th, 2009, 06:56 AM
#14
Just Remembered why I did not follow the multilineorder use case.
In my first step I have the Itemreader, and a compositeItemWriter consisting out of 5 Other writers. 1 of them is the FlatFileItemWriter.
If I use a processor as in the Sample the following happens:
in the process method an Order item is received and a List<String> collection is returned.
That is we have now lost our original Domain Object.
This is fine if you only have 1 Writer which expects it like that, but in my case the other Writers are still expecting the Domain Object and not the collection as returned by the processor?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules