• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reading from two different tables in Spring Batch Item Reader.

 
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

How do i read from from two different tables in spring batch item reader.

I have to consolidate them into a single XML file with two different tags.

Any help is appreciated.

 
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could do a couple of things ...

a. You could always write a query that can "read" from two different tables. You could map the result from these two queries to an object or a composite object containing two objects you want to map to and finally write it out. Just usual usage - nothing different required

assumption: both you tables are in the same database and can be access via a join query

OR

b. You could use a composite Item reader. Here is an example of how that could be done.
https://github.com/langmi/spring-batch-examples-readers/blob/master/src/main/resources/spring/batch/job/readers/jdbc/jdbc-composite-item-reader-job.xml
 
Sivakumar SandeepKumar Jakkaraju
Greenhorn
Posts: 5
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks sam.

I have written my own Composite CUrsorItemReader with help from
https://github.com/langmi/spring-batch-examples-readers/blob/master/src/main/resources/spring/batch/job/readers/jdbc/jdbc-composite-item-reader-job.xml

I am return a object of Class Object and doing the required processing based on instance type.

Thanks for your reply.

Cheers
Sandeep
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic