Hi Guys,
I have a problem when trying to map associations in class inheritance.
Imagine, I have a Class A which has two set associations
one with Class B and one with Class C.
Classes B and C are mapped to the same relation table.
This represents a table per class hierarchy, since Class C extends
Class B. The two classes have a references to the Class A.
So, when I load instances of Class A I want to have two
sets in the instance, one populated with instances of Class B,
the other populated with instances of Class C.
The problem is that when I try to load instances of Class A, I get :
org.hibernate.WrongClassException: Object with id: 1 was not of the specified subclass:......
This is because in the mapping of Class A the one set relation is mapped to the subclass C
and the other is mapped to its superclass B.
I do this because I want each set be populated only with the class it is mapped to.
Do you have any suggestions how could I get the result I want, i.e.
the each set in the Class A be populated only with one type of instances.
I use Hibernate 2.1 and JDK 1.3.
Thank you.
Skyrose.
|