title: How to define primary and foreign key in single hibernate mapping(hbm) file?
body: <p>I want to define a primary key and a foreign key in same hibernate mapping file (hbm) file. I am using hibernate 3.</p>
  
  <p>I don't know how to specify both keys in generated class. The fields in my table are <code>id</code>, <code>eid</code> and <code>fname</code> where <code>id</code> holds the primary key, <code>eid</code> holds the foreign key and <code>fname</code> holds a string.   </p>
  
  <p><strong>assignleave.hbm.xml</strong>:</p>
  
  <pre><code>&lt;hibernate-mapping&gt;
      &lt;class name="assignLeave" table="assignleave"&gt;
          &lt;id name="id" column="id" type="integer"&gt;
              &lt;generator class="assigned"&gt;&lt;/generator&gt;
          &lt;/id&gt;
          &lt;id name="eid" column="eid" type="integer"&gt;
              &lt;generator class="foreign"&gt;&lt;/generator&gt;
          &lt;/id&gt;
         &lt;property name="fname" column="fname" type="string"/&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>