Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Spring Batch - database input, database output

  1. #11
    Join Date
    Jan 2008
    Posts
    12

    Default

    Quote Originally Posted by Dave Syer View Post
    Sorry, I forgot, the parallelJob was added just after m3. You can get it from SVN or from the snapshot builds (backporting to m3 should be trivial up to this point in time).

    As far as 2.0.x goes, we haven't started testing yet, but we will, and I know there are projects using 2.0.x. With x=6 I think you should be OK, but we are only going to test against the latest release (currently x=8). If you need help just ask on the forum.
    Thanks Dave,

    We will be trying it and keep you posted.

    Regards,

    Stefan

  2. #12

    Default

    Hi, thanks for the reply!

    I have a query returning a list of records; for each record in that list there's a subquery returning child records! The subqueries are parameterized with data returned from master record. And all this data will be in the text file.

    The generated file will looks like with this:

    Master Record 1
    Child Record 1 from Master Record 1
    Child Record 2 from Master Record 1
    Child Record 3 from Master Record 1
    ...
    Master Record 2
    Child Record 1 from Master Record 2
    Child Record 2 from Master Record 2
    Child Record 3 from Master Record 2
    Child Record 4 from Master Record 2
    ...

    and so on...


    So, I guess, no, I can't return all data in the same query because the records aren't all the same type!

    By using multiple steps... one approach would be be to read all master-records in a staging table and another step to read slave-records in another staging table! But I think it doesn't solve the issue because I still need maintain two cursor's, one for the staging table and another to the subquery.

  3. #13
    Join Date
    Feb 2008
    Posts
    488

    Default

    One way to do it would be to have your ItemReader query to find all of the Master records. Then you could write your ItemWriter so that for each Master that it receives, it queries for all of the Child records and then writes everything. Something like:

    Code:
    public void write(List<? extends Master> items) {
        for(Master item : items) {
            List<Child> children = queryForChildren(item);
            //write Master and all Child records
        }
    }
    Alternatively, you could do the same thing in an ItemProcessor and then inject the list of Child records onto the Master.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •