File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: Use of set tag in Hibernate mapping file for foreign key