This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Use of set tag in Hibernate mapping file for foreign key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Use of set tag in Hibernate mapping file for foreign key " Watch "Use of set tag in Hibernate mapping file for foreign key " New topic
Author

Use of set tag in Hibernate mapping file for foreign key

nami shekar
Greenhorn

Joined: Sep 14, 2011
Posts: 17
Hi All,
I have 2 tables Person and Employee.
In Person table person's name is primary key.
In Employee table, there is a composite key, which consists of person's name(foreign key) and employee id.

Mapping file for above scenarios are:
for class person:


for employee class:



But I am getting exception.What is the correct way to make foreign key aa part of composite key.
When set will be used???

Thanks in advance
nami shekar
Greenhorn

Joined: Sep 14, 2011
Posts: 17
I have changed my mapping file to:



And i am getting the following exception. Caused by: org.xml.sax.SAXParseException: Attribute "type" must be declared for element type "key-many-to-one".

Please help!!!
Or if the mapping is wrong, let me know how to form a composite key in which one will be foreign key.
Thanks
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Use of set tag in Hibernate mapping file for foreign key
 
jQuery in Action, 3rd edition