title: multiple one-to-many relations ResultSetExtractor
body: <p>Let's say I have an object with two different one-to-many relations. Much like:</p>
  
  <p><code>Customer 1&lt;-&gt;M Brands</code> and <code>Customer 1&lt;-&gt;M Orders</code></p>
  
  <p>And let's say that the my object <code>Customer</code> has two lists related to those two objects.</p>
  
  <p>I've read this example:
  <a href="http://forum.springsource.org/showthread.php?50617-rowmapper-with-one-to-many-query" rel="noreferrer">http://forum.springsource.org/showthread.php?50617-rowmapper-with-one-to-many-query</a>
  which explains how to do it with a single one-to-many relationship. For your convenience here's the <code>ResultSetExtractor</code> override:</p>
  
  <pre><code>private class MyObjectExtractor implements ResultSetExtractor{
  
      public Object extractData(ResultSet rs) throws SQLException, DataAccessException {
          Map&lt;Integer, MyObject&gt; map = new HashMap&lt;Integer, MyObject&gt;();
          MyObject myObject = null;
          while (rs.next()) {
              Integer id = rs.getInt("ID);
              myObject = map.get(id);
            if(myObject == null){
                String description = rs,getString("Description");
                myObject = new MyObject(id, description);
                map.put(id, myObject);
            }
        MyFoo foo = new MyFoo(rs.getString("Foo"), rs.getString("Bar"));
        myObject.add(myFoo);
          }
          return new ArrayList&lt;MyObject&gt;(map.values());;
      }
  }
  </code></pre>
  
  <p>I don't think it covers how to work with both. What would be the cleanest approach? Is there a simpler way than to iterate with conditions? Would sets be better off than lists in this case? </p>