title: Mapping a Map<String, Entity> in hibernate where the String is an attribut of an attribut of the value entity
body: <p>I got a map attribut: Map  working.
  Now i want to change the key so instead of EntityA as a whole it's EntityA.name.</p>
  
  <p>How would i go about this? If it's even possible ...</p>
  
  <p>Posting the code i've atm that works.</p>
  
  <p>Parent:</p>
  
  <pre><code>@Entity
  public class Parent {
  
      ...
  
      @MapKey(name="key")
      @MapKeyClass(Key.class)
      @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
      private Map&lt;Key, Resource&gt; map;
  </code></pre>
  
  <p>Resource:</p>
  
  <pre><code>@Entity
  public class Resource {
  
      ...
  
      @ManyToOne
      @JoinColumn(name = "ID_KEY", nullable = false)
      private Key key;
  </code></pre>
  
  <p>Key:</p>
  
  <pre><code>@Entity
  public class Key {
  
      ...
  
      private String name;
  </code></pre>
  
  <p>I'm looking for way to set Key.name as the map key.</p>
  
  <p>Thanks in advance.</p>