Hi,
How to represent a bidirectional One-To-Many association in XML when joined-subclass is used?
My two classes:
Code:
public class A {
private Long id;
private Set<B> bs = new HashSet<B>();
}
public class B {
private Long id;
private A a;
}
I need a bidirectional OneToMany association between A and B.
My XML mapping:
Code:
<hibernate-mapping>
<class name="A">
<id name="id" access="field">
<column name="aId" />
<generator class="identity" />
</id>
<set name="bs" access="field" table="A_B">
<key column="aId" />
<many-to-many column="bId" class="B" unique="true" />
</set>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="B">
<id name="id" access="field">
<column name="bId" />
<generator class="identity" />
</id>
<join table="A_B" inverse="true" optional="true">
<key column="bId" />
<many-to-one name="a" column="aId" not-null="true" />
</join>
<joined-subclass name="...." table="....">
....
</joined-subclass>
</class>
</hibernate-mapping>
There is an error with the XML syntax, it seems that it's not allowed to use the <join> element with the <joined-subclass> element.
Any idea?
Thanks