title: Many-to-many hibernate xml configuration
body: <p>I have such DB relationship.<br>
  <a href="https://i.stack.imgur.com/Yr570.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yr570.png" alt="db scheme"></a></p>
  
  <p>I want to have many-to-many relationship. Between <code>PLAYER</code> and <code>PRIVILEGE</code>. Could you please help me to fix my .xml configs. </p>
  
  <p><strong>Expected result:</strong>
  I want to be able to execute: <code>String hql = "from Player as p right outer join p.privilages as priv";</code></p>
  
  <p><strong>Actual:</strong>
  So far I get:</p>
  
  <blockquote>
    <p>org.hibernate.MappingException: Foreign key (FK8CD18EE134F64423:PLAYER
    [ID])) must have same number of columns as the referenced primary key
    (PRIVILAGE [ID,PRIVILAGE])</p>
  </blockquote>
  
  <pre><code>&lt;hibernate-mapping&gt;
      &lt;class name="model.Privilage" table="PRIVILAGE"&gt;
          &lt;id name="id" type="int" &gt;
              &lt;column name="ID"  precision="5" scale="0"/&gt;
              &lt;generator class="increment"/&gt;
          &lt;/id&gt;
  
          &lt;set name="players" table="PLAYER"
               inverse="false" lazy="true" fetch="select" cascade="all" &gt;
              &lt;key&gt;
                  &lt;column name="ID"/&gt;
              &lt;/key&gt;
              &lt;many-to-many entity-name="model.Player"&gt;
                  &lt;column name="ID" not-null="true" /&gt;
              &lt;/many-to-many&gt;
          &lt;/set&gt;
  
          &lt;property name="privilage" type="string"&gt;
              &lt;column name="PRIVILAGE" length="20" not-null="true" /&gt;
          &lt;/property&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>and </p>
  
  <pre><code>&lt;class name="model.Player" table="PLAYER"&gt;
      &lt;id name="playerId" type="int" &gt;
          &lt;column name="ID" precision="5" scale="0"/&gt;
          &lt;generator class="sequence"&gt;
              &lt;param name="sequence"&gt;PLAYER_SEQ&lt;/param&gt;
          &lt;/generator&gt;
      &lt;/id&gt;
      &lt;set name="privilages" table="PRIVILAGE"
           inverse="false" lazy="true" fetch="select" cascade="all" &gt;
          &lt;key&gt;
              &lt;column name="ID"/&gt;
          &lt;/key&gt;
          &lt;many-to-many entity-name="model.Privilage"&gt;
              &lt;column name="PRIVILAGE" not-null="true" /&gt;
          &lt;/many-to-many&gt;
      &lt;/set&gt;
      &lt;!-- ... --&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p></p>