I have this mapping (simplified)
<class name="Component" table="comp_catalog">
...
<many-to-one name="currentVersion" class="CompVersion" property-ref="CurrentCompVersion" cascade="save-update">
<formula>component_id</formula>
<column name="current_version" not-null="true" />
</many-to-one>
...
</class>
<class name="CompVersion" table="comp_versions">
...
<properties name="CurrentCompVersion" unique="true">
<many-to-one name="component" class="Component" column="component_id"/>
<property name="version" column="version" insert="true" update="true"/>
</properties>
...
</class>
in code i have an instance of Component entityComponent and an instance of CompVersion compVersion,
...
EntityManager em = getEntityManager();
entityComponent.setCurrentVersion(compVersion);
persistEntity(em, compVersion);
persistEntity(em, entityComponent);
...
it inserts into both comp_catalog and comp_versions, comp_catalog.current_version saves correctly with the value (say 1), but comp_versions.version does not save the same value (it is 0).
What am i doing wrong?
Thanks
Shannon
|