title: Many to many hibernate mapping with extra columns?
body: <p>Hi i have many to many mapping with extra columns in the join table.
  table structure look like this.</p>
  
  <pre><code>table vendor{vendor_id, vendor_name, vendor_password, etc...}
  table student{student_id, student_name, student_password, etc..}
  table test{test_id, test_subject, test_price,test_level, etc..}
  </code></pre>
  
  <p>Relations as follows</p>
  
  <pre><code>vendor to test --&gt; many-to-many
  student to test --&gt; many-to-many
  </code></pre>
  
  <p>link </p>
  
  <pre><code>table vendor_student_test{vendor_id, student_id, test_id, purchasedDate, assignedDate, writtenDate, result}
  </code></pre>
  
  <p>i created POJO classes as follows</p>
  
  <ol>
  <li>Vendor.java</li>
  </ol>
  
  <blockquote>
  <pre><code>public class Vendor {
  Long vendorId;
  Set&lt;VendorStudentTest&gt; tests;
  //set and get
  }
  </code></pre>
  </blockquote>
  
  <ol>
  <li>Student.java</li>
  </ol>
  
  <blockquote>
  <pre><code>public class Student{
  Long studentId;
  Set&lt;VendorStudentTest&gt; tests;
  //set and get
  }
  </code></pre>
  </blockquote>
  
  <ol>
  <li>Test.java</li>
  </ol>
  
  <blockquote>
  <pre><code>public class Test{
  Long test_id;
  double test_price;
  //set and get and remaining fields
  }
  </code></pre>
  </blockquote>
  
  <ol>
  <li>VendorStudentTest.java</li>
  </ol>
  
  <blockquote>
  <pre><code>public class VendorStudentTest{
  public VendorStudentTestPK vendorStudentTestPK;
  Date purchasedDate;
  Date assignDate;
  Date writtenDate;
  double result;
  //set and get accordingly
  }
  </code></pre>
  </blockquote>
  
  <ol>
  <li>VendorStudentTestPK.java</li>
  </ol>
  
  <blockquote>
  <pre><code>public class VendorStudentTestPK{
  Long vendor_id;
  Long student_id;
  Long test_id;
  }
  </code></pre>
  </blockquote>
  
  <p>Hibernate mapping files as follows</p>
  
  <p>vendor.hbm.xml</p>
  
  <pre><code>&lt;set name="tests" table="vendor_student_test"
                  inverse="true" lazy="true" fetch="select"&gt;
              &lt;key&gt;
                  &lt;column name="vendor_id" not-null="true" /&gt;
              &lt;/key&gt;
              &lt;one-to-many class="VendorStudentTest" /&gt;
          &lt;/set&gt;
  </code></pre>
  
  <p>vendor_student_test.hbm.xml</p>
  
  <pre><code>    &lt;composite-id name="vendorStudentTestPK"
          class="com.onlineexam.model.VendorStudentTestPK"&gt;
  
          &lt;key-property name="vendor" column="vendor_id"
              type="java.lang.Long" /&gt;
          &lt;key-property name="student" column="student_id"
              type="java.lang.Long" /&gt;
          &lt;key-property name="test" column="test_id" type="java.lang.Long" /&gt;
  
      &lt;/composite-id&gt;
  </code></pre>
  
  <p>student.hbm.xml</p>
  
  <pre><code>&lt;set name="tests" table="vendor_student_test"
                  inverse="true" lazy="true" fetch="select"&gt;
              &lt;key&gt;
                  &lt;column name="student_id" not-null="true" /&gt;
              &lt;/key&gt;
              &lt;one-to-many class="VendorStudentTest" /&gt;
          &lt;/set&gt;
  </code></pre>
  
  <p>test.hbm.xml</p>
  
  <pre><code>//this is mapped to other table 
  </code></pre>
  
  <p>I am new to hibernate, Is this correct mapping?</p>