title: How to annotate Map<Entity,INTEGER> with JPA?
body: <p>I have this map:</p>
  
  <pre><code>Map&lt;Owner, Integer&gt; ownerSharesMap = new HashMap&lt;&gt;();
  </code></pre>
  
  <p>I know how to map a <code>HashMap</code> with <code>@OneToMany</code> relation that has a primitive type as key, but I googled a lot and didn't find a way to map the above <code>HashMap</code> with JPA.
  I see two options though:</p>
  
  <p>to change my <code>HashMap</code> to this: (in which the uuid is the key column of <code>Owner</code>)</p>
  
  <pre><code>Map&lt;UUID, Integer&gt; ownerIdSharesMap = new HashMap&lt;&gt;();
  </code></pre>
  
  <p>or
  create a class like this :</p>
  
  <pre><code>public class Share{
    int count;
    Owner owner
  }
  </code></pre>
  
  <p>then persist this Set:</p>
  
  <pre><code>Set&lt;Share&gt; shares;
  </code></pre>
  
  <p>what do you suggest? is there a way to annotate first Map with JPA or should I use the later solutions?</p>
  
  <p>Note that in my project, querying performance is the main concern but I want clean OOD too.</p>
  
  <p>Thanks.</p>