Hi Guys,
I have the following problem.
I have a class A which has two associations one to many associations
with classes B and C.
I use a List object to handle these associations.
The classes B ans C are mapped to the same table. They both
extend class D.
In the mapping xml file of class A I have the following entries
<bag name="ListB" inverse="true" cascade="all-delete-orphan" outer-join="true"> <key column="id"/> <one-to-many class="bla.bla.classD"/> </bag>
<bag name="ListC" inverse="true" cascade="all-delete-orphan" outer-join="true"> <key column="id"/> <one-to-many class="bla.bla.classD"/> </bag>
As you can see the one-to-many associations for both the lists is mapped to the class D, which is the superclass of B and C.
So when I load my object A I got two lists which are filled in with the same instances of class B and C.
How could I make it possible for the two lists to be filled in with only one
type of class : ListB with instances of class B only and ListC with instances of classC only.
If I try to map each one-to-many association relation with the concrete class type, classB for ListB and classC for List C I got:
org.hibernate.WrongClassException: Object with id: 1 was not of the specified subclass:......
Do you have any suggestions how could I make it work ?
I use Hibernate 2.1 and JDK 1.3.
Thank you.
Skyrose.
|