Hi Patrik,
Yup, that's what we tried. We ran into a problem though. Here's the definition:
Entity PropertyData {
- List<@PropertyItem> items fetch="join" cascade="all" inverse
}
ValueObject PropertyItem {
String stuff nullable
}
When we did that, it created the correct one-to-many Hibernate mapping like this:
<hibernate-mapping default-cascade="none" default-access="property" default-lazy="true" auto-import="true">
<class name="com.foo.PropertyData" table="OM_PROPERTY_DATA" mutable="true" polymorphism="implicit" dynamic-update="false" dynamic-insert="false" select-before-update="false" optimistic-lock="version">
...
<list name="items" inverse="true" cascade="all" fetch="join" lazy="false" mutable="true" optimistic-lock="true" embed-xml="true">
<key column="C_PROPERTY_DATA" on-delete="noaction"/>
<index column="C_ITEM_INDEX"/>
<one-to-many class="com.foo.PropertyItem" not-found="exception" embed-xml="true"/>
</list>
</class>
</hibernate-mapping>
Then when we saved a PropertyData with PropertyItems, Hibernate created all the PropertyData and PropertyItem records, but the C_PROPERTY_DATA foreign key column in PropertyItem was null. So when we retrieve the PropertyData again, it does not have any PropertyItems attached to it. Isn't "inverse" in Hibernate only used for bi-directional relationships? How does the C_PROPERTY_DATA key get set?
Please let me know if I broke something or if we are doing something wrong.
Thanks!
--Polly