Is it possible to map a many-to-many association that contains extra properties on the join table with an <idbag> and <composite-element>? This is on v2.1.4.
I've tried the mapping snippet below:
Code:
<class name="ClassA" table="class_a" proxy="ClassA">
<id name="oid" column="oid" type="long" unsaved-value="0">
<generator class="sequence">
<param name="sequence">fooseq</param>
</generator>
</id>
<property name="title" column="title" type="string"/>
<idbag name="collectionB" table="join_table" lazy="true">
<collection-id column="oid" type="long">
<generator class="sequence">
<param name="sequence">fooseq</param>
</generator>
</collection-id>
<key column="this_class_oid"/>
<composite-element class="ClassA$ClassX">
<property name="propA" column="propa" type="string"/>
<property name="propB" column="propb" type="string"/>
<many-to-one name="classY" column="class_y_oid" class="ClassY" outer-join="true"/>
</composite-element>
</idbag>
I get the right type of object, the extra properties (propA, propB) are correct, the associated class (classY) is correct, but for some reason the id of every one of the join table objects is 0. What I mean is, calling getClassX().getOID() always returns 0 for each member of the collection classA.getCollectionB().
Is this type of mapping supported? Or should I just give up and make ClassX a full-blown domain object and map it with a standard many-to-one?
Thanks!