• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

composite key in annotations

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
author and cow tipper
Posts: 5006
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
I brought this back from the farm where they grow the tiny ads:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic