Announcement Announcement Module
Collapse
No announcement yet.
Help: RowMapper vs ResultSetExtractor Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help: RowMapper vs ResultSetExtractor

    I am new to SpringFramework. I am confused by the usage between RowMapper and ResultSetExtractor.

    It seems I have to implement 2 different interfaces for the same function, ie.

    List l = JdbcTemplate.query("select * from Product", aRowMapperClass);

    and

    Product p = (Product) JdbcTemplate.query("select * from Product where id = 1", aResultSetExtractorClass);

    thanks.

    java9394

  • #2
    RowMapper is a higher level interface than ResultSetExtractor. You would use the latter if you want to deal with the entire ResultSet, and translate that to some sort of returned object, whereas RowMapper pre-supposes that each row in the ResultSet will be mapped to a returned object of some sort. The callback will happen once for each row.

    Comment

    Working...
    X