This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

composite key in annotations

 
rudresh kumar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

i have implemented the composite key in hbm file, which is as below (child.hbm)

<composite-id>
<key-many-to-one name="master" class="com.bo.master" column="MASTER_ID" ></key-many-to-one>
<key-property name="child" type="java.lang.Integer" column="CHILD_ID"></key-property>
</composite-id>

This works fine, but i would like to convert this into a annotations and remove the hbm files. Can i know how the definition would be for the annotations on the child class (com.bo.child) for composite key.

Thanks

 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a "Team has many Players" example on Hibernate Tutorials Website that shows the basics of a one to many or many to one relationship mapped in Hibernate with JPA annotations:










That demonstrates a simple relationship. Just apply the corresponding Team and Player values to your scenario, and you'll have it mapped!

Example of Mapping One To Many Associations with Hibernate and JPA Annotations

-Cameron McKenzie

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic