Hi
hibernate 3.2
I'm having a one-to-many relationship, the parent's id is generated and the child is only referencing the paren'ts id :
Code:
<class name="my.Parent" table="PARENT_TABLE" mutable="false">
<id name="id" type="long" column="PARENT_DB_ID">
<generator class="sequence">
<param name="sequence">PARENT_DB_ID</param>
</generator>
</id>
<set name="children" cascade="all" inverse="true">
<key column="PARENT_DB_ID"/>
<one-to-many class="my.Child"/>
</set>
</class>
Code:
<class name="my.Child" table="CHILD_TABLE" mutable="false">
<id name="id" type="long" column="CHILD_DB_ID">
<generator class="sequence">
<param name="sequence">CHILD_DB_ID</param>
</generator>
</id>
<property name="parent" column="PARENT_DB_ID" type="long"/>
</class>
My issue is that when I save the parent, hibernate don't set the Child.parent property with the generated parent's id, from the documentation (
http://www.hibernate.org/209.html) this behavior seems straightforward when the child is referencing the parent through a many-to-one but for legacy reason I don't want to update the child class; is there a way to do this only using the mapping files ?
Thanks