Given the following classes:
ClassA
{
int id;
ClassB[] listOfClassB;
}
ClassB
{
int id;
}
ClassC extends ClassB
{
int id;
ClassB x;
ClassB y;
}
Described as follows in my OJB repository:
ClassA has a many-to-many relationship to ClassB represented by the
listOfClassB collection. This is implemented as a non-decomposed m-to-n
using an indirection table. That is, many Class A objects hold a collection
to potentially the same ClassB objects. Note that since ClassC extends
ClassB that the same should follow for ClassC objects. That is, many ClassA
objects should be able to hold a collection that contains reference to both
ClassB and ClassC objects and more importantly the same ClassB and ClassC
objects.
ClassC is described as an extent-class in the ClassB class-descriptor
because it extends ClassB.
All works fine when only instances of ClassB are stored in the listOfClassB
on ClassA except when an instance of ClassC is added to the listOfClassB
attribute on an instance of ClassA. In this case, OJB generates a duplicate
INSERT on the instance of ClassB that is assigned to x in the ClassC object.
The problem is occuring when both an instance of ClassB and an instance of
ClassC (which also holds a reference to the same instance of ClassB) is
stored in the listOfClassB attribute on a ClassA object .
The ClassC object really has a many-to-one relationship to ClassB objects.
It is not clear how to model this in OJB
Let me know if you need more information such as the repository entries for
these classes. I very much need to accommodate this scenario.