• 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

Difference between RowCallbackHandler and RowMapper

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is difference between RowCallbackHandler and RowMapper?
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both RowCallBackHandler and RowMapper are both for retrieving the results from a ResultSet which takes the responsibility to process each row of data in the ResultSet. Both interface methods should not call next() on the ResultSet. It requires to extract values of the current row and process the data on per-row basis.

RowCallBackHandler's processRow(ResultSet rs) does not return object which is having the result.If require it can store the result in its instance variable and then make it available it to DAO but for this it requires to be designed as stateful.
So this type of method(processRow()) is generally implemented to process the result like preparing XML document with the result data.

But RowMapper's mapRow(ResultSet rs, int rowNum) can return an Object representing the result object for the current row.
In general this interface is designed as stateless to make it reusable and reduce the memory requirements.
 
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic