This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Use of set tag in Hibernate mapping file for foreign key
 
Similar Threads
Integrity constraint violation: for Hibernate Insert
Query returs empty list but getting results in TOAD
Mapping For CompositeID
Mapping Question
Unable to find Data source