This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Composite foreign key mapping in Hibernate 3 using JPA Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Composite foreign key mapping in Hibernate 3 using JPA" Watch "Composite foreign key mapping in Hibernate 3 using JPA" New topic
Author

Composite foreign key mapping in Hibernate 3 using JPA

aman thind
Ranch Hand

Joined: Jun 29, 2007
Posts: 71
Hi All,

We have a table
A(a_id, name) where a_id is primary key
B(b_id, name) where b_id is primary key
C(a_id, b_id) where a_id & b_id are composite key and foreign key to table 'A' & 'B'

We have proper mapping for table 'A' & 'B' in hibernate 3 using annotation.

But we are not sure how to create entity class for table 'C', since it does not have any primary key.
We wanted to know how to map composite foreign key.

Can any one please help us how to create the entity class for table 'C'
aman thind
Ranch Hand

Joined: Jun 29, 2007
Posts: 71
Thanks. We made some small changes since our composite primary key was a combination of foreign keys but it worked
Thanks once again.
 
Consider Paul's rocket mass heater.
 
subject: Composite foreign key mapping in Hibernate 3 using JPA
 
Similar Threads
[Solved] [Problem] Referencing two objects with OneToOne relation
Hibernate Criteria can't create joins for Embedded objects
Parent class id value instead of child's id used incorrectly for querying Set assoc.
Hibernate many-to-one composite key as foreign key
about one to one