title: How to map additional column of many-to-many join table to the association map key?
body: <p>There is an entity call <strong>Version</strong> and this entity has an inner join many-to-many relationship. The bridge table <strong>VER_EQUIVALENTS</strong> has columns [VER_ID, EQUIVALENT_VER_ID, CODE] and the CODE column contains the code of the equivalent version.</p>
  <p>This is how I implemented this relationship.</p>
  <pre class="lang-java prettyprint-override"><code>public class Version {
          
     private String code;
           
     @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
     @JoinTable(
        name = &quot;VER_EQUIVALENTS&quot;,
        joinColumns = {@JoinColumn(name = &quot;VER_ID&quot;)},
        inverseJoinColumns = {@JoinColumn(name = &quot;EQUIVALENT_VER_ID&quot;)}
     )
     @MapKey(name = &quot;code&quot;)
     @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
     private Map&lt;String, Version&gt; equivalentVersions = new HashMap&lt;String, Version&gt;();
          
  }
  </code></pre>
  <p>This is what I got when I try to insert a version contains equivalent versions.</p>
  <pre><code>ORA-01400: cannot insert NULL into (&quot;VER_EQUIVALENTS&quot;.&quot;CODE&quot;)  
  </code></pre>
  <p>What can I do to set the <strong>CODE</strong> value?</p>