title: One to many Spring Result Mapping
body: <p>This is my first time posting problem hope someone can help me on this mapping the result into:</p>
  
  <pre><code>List&lt;Clients&gt;
  </code></pre>
  
  <p>So here's the sample result from database:</p>
  
  <pre><code>NameID   |  Name      | Notes                  | Date
  1        | Client1    | Get this on monday.    | null
  1        | Client1    | Get this on wednesday. | null
  2        | Client2    | Meet on saturday.      | null
  </code></pre>
  
  <p>So here's my mode (java class).</p>
  
  <p><strong>Name.java</strong></p>
  
  <pre><code>private int NameId;
  private String ClientName;
  .. getter and setter
  </code></pre>
  
  <p><strong>Notes.java</strong></p>
  
  <pre><code>private int NotesId;
  private String ClientNote;
  .. getter and setter
  </code></pre>
  
  <p><strong>Clients.java</strong></p>
  
  <pre><code>private Name name;
  private List&lt;Notes&gt; notes;
  .. getter and setter
  </code></pre>
  
  <p><strong>ClientResultSet.java</strong></p>
  
  <pre><code>class ClientResultSet implements ResultSetExtractor&lt;List&lt;Clients&gt;&gt;{
  
      @Override
      public List&lt;Clients&gt; extractData(ResultSet rs) throws SQLException, DataAccessException {
          Map&lt;int, Clients&gt; map = new HashMap&lt;int, Clients&gt;();
          while(rs.next()) {
              int NameId= rs.getInt("NameId");
              Clients clients= map.get(contactId);
  
              if (clients== null) {
  
                  // I'm losing my thoughts here. :'(
              }
          }
          return null;
      }
  
  }
  </code></pre>
  
  <p>Result I want to achieve:</p>
  
  <pre><code>[
    {
      name:{
        NameId: 1,
        Name: "Client1"
      },
      notes[
        {
           NotesId: 1,
           ClientNote: "Get this on monday",
           Date: null
        },
        {
           NoteId: 2,
           ClientNote: "Get this on wednesday",
           Date: null
        }
      ]
    },
    {
      name:{},
      notes:[{},{}]
    }
    ... and so on
  ]
  </code></pre>
  
  <p>I'm reading ResultSetExtractor but I don't know how to implement it. Thanks in advance and have a good day.</p>