Thanks for any help! Assume I have three classes:
Code:
public class ParentClassAImpl implements ParentInterface {
private Set<ChildClass> childClasses = new HashSet<ChildClass>();
}
public class ParentClassBImpl implements ParentInterface {
private Set<ChildClass> childClasses = new HashSet<ChildClass>();
}
public class ChildClass {
private ParentInterface parentInterface;
}
Assume a child can have an association to either ParentClassA or ParentClassB. In the ChildClass.hbm.xml, I would map this with the <any> relationship:
Code:
<any name="parentInterface" meta-type="string" id-type="string">
<meta-value value="A" class="ParentClassAImpl"/>
<meta-value value="B" class="ParentClassBImpl"/>
<column name="entity_type"/>
<column name="entity_id"/>
</any>
However, how do I map a one-to-many Set<ChildClass> in ParentClassAImpl.hbm.xml and ParentClassBImpl.xml? I basically want ParentClassAImpl.childClasses = all ChildClasses where entity_type = A and entity_id = ParentClassAImpl.id
I do not see how to express this in a mapping file given that the format for a set only allows you to specify a key column.
In summary: I can map a child class to have an <any> relationship back to a parent, but how do I map the set of children for a particular parent?
Thanks so much for any help!
Arthur Loder
Software Engineer
Comcast Interactive Media