Results 1 to 2 of 2

Thread: Help: RowMapper vs ResultSetExtractor

  1. #1
    Join Date
    Aug 2004
    Posts
    8

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    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.
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

Similar Threads

  1. Using ResultSetExtractor and RowMapper
    By too_many_details in forum Data
    Replies: 0
    Last Post: Aug 19th, 2005, 05:23 AM
  2. rowMapper or MappingSqlQuery?
    By spectrus in forum Data
    Replies: 4
    Last Post: Jul 27th, 2005, 12:42 PM
  3. JDBC RowMapper and foreign keys
    By romanf in forum Data
    Replies: 2
    Last Post: Jul 6th, 2005, 12:42 AM
  4. Replies: 2
    Last Post: May 11th, 2005, 02:56 PM
  5. Reusable ResultSetExtractor available?
    By kenfitz in forum Data
    Replies: 4
    Last Post: Mar 28th, 2005, 07:20 PM

Posting Permissions

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