Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use of set tag in Hibernate mapping file for foreign key

 
nami shekar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic