title: spring jdbctemplate hold data in map key is string and value Object
body: <p>Hi need to hold the resultset as key value pair  key is string coming from database
  and have multiple value corresponding to that keys values are also coming from database
  map looking like this Map></p>
  
  <p>My Code is:</p>
  
  <p>It is resultset extractor: In this I am iterating the resultset and adding it to the map.</p>
  
  <p>ResultSetExtractor resultExtractor = new ResultSetExtractor() {</p>
  
  <pre><code>    public Object extractData(ResultSet rs) throws SQLException,
              DataAccessException {
          MyDataBean dataBean = new MyDataBean();
          List&lt;MyDataBean &gt; myDataBeanList = new ArrayList&lt;MyDataBean &gt;();
          Map&lt;String, List&lt;MyBean&gt;&gt; myMap = new HashMap&lt;String, List&lt;MyDataBean&gt;&gt;();
          while (rs.next()) {
              String propertyNumber = rs.getString("PROPERTY_NUMBER");
              dataBean.setAccountNumber(rs.getLong("ACCOUNT_NUMBER"));
              dataBean.setAmount(rs.getDouble("AMOUNT"));
              myDataBeanList .add(dataBean);
              myMap .put(propertyNumber, argusDataList);
          }
          return myMap ;
      }
  };
  </code></pre>
  
  <p>this is method::: here I am firing the query and passing the resultExtractor.</p>
  
  <pre><code>@SuppressWarnings("unchecked")
  public Map&lt;String, List&lt;MyDataBean&gt;&gt; getData()
          throws DataAccessException, GeneralFailureException {
  
      Map&lt;String, List&lt;MyDataBean&gt;&gt; myMap= null;
      try {
          myMap= jdbcTemplate.query(MyQuery,
                  resultExtractor );
      } catch (DataAccessException ex) {
          throw new GeneralFailureException("SQL Exception:xyzClass::"
                  + ex);
      } catch (Exception ex) {
          throw new GeneralFailureException(
                  "GeneralFailureException::xyzClass::::" + ex);
      }
  
      return myMap;
  }
  </code></pre>
  
  <p>in result set extractor I am holding data in a map but in output it is giving all keys of map but only the last value which added to the list m not getting why please help me to resolve this issue </p>
  
  <p>thanks in advance</p>