title: hibernate - MapKeyColumn excluded in insert
body: <p>I have two Entity classes as follows in a sample application:</p>
  
  <pre><code>@Entity
  public class Person {
  ...
    @OneToMany(mappedBy = "owner", cascade= CascadeType.ALL)
    @MapKeyColumn(name="phone_type")
    private Map&lt;String, Phone&gt; phones = new HashMap&lt;String, Phone&gt;();
  
    public Map&lt;String, Phone&gt; getPhones() {
      return phones;
    }
  
    public void setPhones(Map&lt;String, Phone&gt; phones) {
      this.phones = phones;
    }
  ...
  }
  
  @Entity
  public class Phone {
  ...
    @ManyToOne
    private Person owner;
  
    public Person getOwner() {
      return owner;
    }
  
    public void setOwner(Person owner) {
      this.owner = owner;
    }
  ...
  }
  </code></pre>
  
  <p>Even though I've not included a field for phone_type in the Phone object, I'd want it to be persisted in the DB based on it's value in the Person classes HashMap.
  I've not added the field to the Phone object to avoid managing data redundantly - as phone_type is already present as the key in the map.</p>
  
  <p>When I try to persist a Person object I see that the hibernate runs inserts excluding the phone_type column - for example:</p>
  
  <pre><code>insert into person (first_name, last_name, id) values (?, ?, ?)
  
  insert into phone (number, owner_id, id) values (?, ?, ?)
  </code></pre>
  
  <p>Am I missing something for this to work? As far as I can tell my example copies the one here: <a href="https://en.wikibooks.org/wiki/Java_Persistence/Relationships#Map_Key_Columns_.28JPA_2.0.29" rel="nofollow">https://en.wikibooks.org/wiki/Java_Persistence/Relationships#Map_Key_Columns_.28JPA_2.0.29</a> , yet I can't really get it to work.</p>
  
  <p>Thank you for any help!</p>