I am trying to add to my class (class A) a component (class B) that has a one-to-many mapping to a third class (class C) for several properties of class A.
Code:
<component name="b1" lazy="true" class="com.xyz.B">
<set cascade="all-delete-orphan" [b]where="entity_type='b1'"[/b] lazy="false" name="localizedStrings">
<key column="entity_id"/>
<one-to-many class="com.xyz.C"/>
</set>
</component>
<component name="b2" lazy="true" class="com.xyz.B">
<set cascade="all-delete-orphan" [b]where="entity_type='b2'"[/b] lazy="false" name="localizedStrings">
<key column="entity_id"/>
<one-to-many class="com.xyz.C"/>
</set>
</component>
We use XDoclet to generate the mappings. The
where="entity_type='b1'" in bold were added manually.
I have a class A which has multiple properties of class B. Class B in turn has a one-to-many mapping to class C.
Code:
class A {
...
public B b1;
public B b2;
...
}
As I mentioned above, we added the
where="entity_type=..." condition to differentiate between instances of C that belong to different properties of A, in this case b1 and b2.
The problem is that when I load an instance of class A, both b1 and b2 are initialized with the same instances of C, which means my where clauses are
being ignored.
Is there any way to do this?