title: How to make Hibernate Spring Repository to return HashMap
body: <p>Generally we write the query as </p>
  
  <pre><code>@Query("SELECT a FROM Foo a WHERE a.someId = :id")
  Map&lt;Long, Foo&gt; findAllBySomeId(Long id)
  </code></pre>
  
  <p>Is there a way to get it HashMap  instead of List.<br>
  I want the key of the Hashmap's key=someId and Value as Foo.</p>
  
  <p>I tried like this   </p>
  
  <pre><code>@Query("SELECT new map (a.someId, a) FROM Foo a WHERE a.someId = :id")
  Map&lt;Long, Foo&gt; findAllBySomeIdAsMap(Long id);
  </code></pre>
  
  <p>but it returned two items but a.someId as Value and key as 0;</p>
  
  <pre><code>0=someId
  1=Foo
  </code></pre>