Announcement Announcement Module
Collapse
No announcement yet.
How to map multiple rows into one object? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to map multiple rows into one object?

    Using RowMapper, we can map one row into one object (or more, though a little weird).
    But how to use RowMapper to map multiple rows into one object?
    For example,

    rows from database:
    Code:
    id      value	catagory
    1        spring	  season
    1        warm 	  temperature
    2        summer	  season
    2        hot	  temperature
    Mapped into two objects:
    Code:
    Season spring = new Season("spring", "warm");
    Season summer = new Season("summer", "hot");
    
    public class Season{
           private String name;
           private String temperature;
           ....
    }

  • #2
    It's similar to pivot table function in database.
    But we can't use it here.

    Comment


    • #3
      You should try using the ResultSetExtractor interface

      http://static.springsource.org/sprin...Extractor.html

      Comment

      Working...
      X