Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Reading from two different tables in Spring Batch Item Reader.

 
  • Mark post as helpful
  • send pies
  • 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: 607
Firefox Browser Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic