First of all I want to thank Christian for his excellent book Hibernate in Action.
Nevertheless I have a question regarding the table per subclass inheritance strategy. The example in the book uses the BillingDetails, Creditcard and BankAccount classes on page 204.
Let's say that you would use Person, Customer and Employee classes respectively.
Is it possible to have a Customer and Employee both refer to one row in the person table (using the joined strategy as described on pg 206-207)? All linked together with the same id?
Arguably ... a person can be both a customer and an employee (and even a systemuser).
If the answer is yes... why does Hibernate have problems loading a Customer and an Employee instance (referring to one person row) at the same time?
When having an invoice that references a customer and an employee, Hibernate doesn't
seem to differentiate between those two when setting the properties which turns into a class cast exception.
|