Hello,
I have read docs and forum on how to setup Master-Detail with composite id and the only way we got it working is to use composite-element on the detail object, but this is kind restrictive, we could have problems in future to reference it and querying.
I got all kind of errors as i tried different variation to the code below: often tells to use "insert or update=false" but then if i do it says "not allowed in the key element", other cases try to do an update instead of an insert, others try to insert but you can see the master_id is null...
what is wrong with the config below?
Thank you.
Hibernate version: 3.2.2.ga
Mapping documents:
<class name="Root" table="root">
<id name="id" type="long">
<generator class="sequence">
<param name="sequence">seq_root</param>
</generator>
</id>
<version column="ver" name="ver" type="long" />
<property name="myprop" type="string" />
......
<joined-subclass name="Master" table="master">
<key column="master_id " not-null="true" />
<property name="myname" type="string"/>
<bag name="details" cascade="all" order-by="row_num">
<key column="master_id" not-null="true" />
<one-to-many class="Detail"/>
</bag>
</joined-subclass>
</class>
<class name="Detail" table="detail">
<composite-id>
<key-property name="mId" type="long" column="master_id" />
<key-property name="numRow" type="int" column="num_row"/>
</composite-id>
<property name="mydesc" type="string" />
</class>
|