Joined: Wed Feb 15, 2006 7:51 pm Posts: 9 Location: Sydney, Australia
|
I'm trying to map a legacy database structure into a new Hibernate-based application. I can't figure out how (or if it's possible) to map one particular aspect of it.
There are three tables involved:
Employee
- employeeId
- name
- dateOfBirth
- employeeNumber
Visitor
- visitorId
- name
- dateOfBirth
- referralCode
Accident
- victimType
- victimId
There are two types of persons: Employees and Visitors. Either may have an accident, so the Accident table has a column for the victim (person) type and Id.
In Java, I wanted to create a Person interface that the Employee and Visitor classes would implement. Then the Accident objects wouldn't need to know the type of Person that had the Accident. And I want Hibernate to look after instantiating the appropriate type (Visitor or Employee) depending on the value of the victimType column.
Any ideas on how this can be accomplished?
thanks!
thomas
|
|