XML : xml Hibernate mapping, many to one with composite ids and different column names

I am a beginner in hibernate. Basically I want to make UserId1 and UserId2 foreign keys of UserId. I Know I need to use many to one and one to many, but I can't seem to understand how to use them because my columns have different names. Any help is appreciated!
This is my hibernate.hbm.xml file:

  <?xml version="1.0"?>  <!DOCTYPE hibernate-mapping PUBLIC          "-//Hibernate/Hibernate Mapping DTD 3.0//EN"          "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">  <hibernate-mapping>      <class name="objects.UserProfile" table="userProfiles">          <id name="UserId" column="UserProfileId">              <generator class="native"/>          </id>      </class>      <class name="objects.UserTrack" table="userTrack">          <composite-id>              <key-property name="UserId1" column="UserProfileId1" type="integer" />                    <key-property name="UserId2" column="UserProfileId2" type="integer" />                     </composite-id>         </class>  </hibernate-mapping>    

No comments:

Post a Comment