Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 5009
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

 
Water proof donuts! Eat them while reading this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic