tirtzab wrote:
I have a one-to-one mapping based on a foreign key association. It is able to pull the related data.
The problem is: when saving it does not put in an id into the foreign key of the related data .
<class name="net.idt.ReportEngine.dao.Query_Group" table="tre.Query_Group">
<id name="id" column="query_group_id" type="long">
<generator class="sequence">
<param name="sequence">tre.QUERY_GROUP_SEQ</param>
</generator>
</id>
<property name="interval" type="string"/>
<property name="last_run_dte" type="timestamp"/>
<property name="group_name" type="string"/>
<property name="group_status_cde" type="string"/>
<one-to-one name="groupEmailInfo" class="net.idt.ReportEngine.dao.GroupEmailInfo"
property-ref="group_id" cascade="all" constrained ="true"/>
</class>
<class name="net.idt.ReportEngine.dao.GroupEmailInfo" table="tre.Group_Email_Info">
<id name="id" column="Group_Email_Info_Id" type="long" unsaved-value="0">
<generator class="increment"/>
</id>
<property name="group_id" type="long"/>
<property name="subject" type="string"/>
<property name="body" type="string"/>
<property name="from_address" type="string"/>
</class>
To clarify: My Query_Group class contains GroupEmailInfo as a member.
A select on a specific Query_Group includes the correct GroupEmailInfo.
However when saving a new Query_Group (with a GroupEmailInfo ) then
the GroupEmailInfo that is inserted into the db has a null value in group_id(the foregn key).
<one-to-one>'s need to be defined on both sides.
Look at the example on page 61 of the 3.0.5 docs - section 6.1.11.