Hey guys, firstly, this isn't a "GIVF ANSWER NOW!!11" type question, but more a.."Is this actually supported?" type discussion.
I'll post the bare basics of my mappings below, and then discuss it.
XML:
Code:
<class name="cdl.impl.XMLImpl" table="XML">
<id name="XMLID" column="XMLID" type ="java.lang.Long" unsaved-value="null">
<generator class="identity"/>
</id>
<one-to-one name="Matter" class="cdl.impl.MatterImpl" cascade="all"/>
Matter:
Code:
<class name="cdl.impl.MatterImpl" table="Matter">
<id name="XMLID" column="XMLID" type ="java.lang.Long" unsaved-value="null">
<generator class="foreign">
<param name="property">XML</param>
</generator>
</id>
<one-to-one name="XML" class="cdl.impl.XMLImpl" constrained="true"/>
<one-to-one name="Properties" class="cdl.impl.PropertiesImpl" />
Properties:
Code:
<class name="cdl.impl.PropertiesImpl" table="Properties">
<id name="XMLID" column="XMLID" type ="java.lang.Long" unsaved-value="null">
<generator class="foreign">
<param name="property">Matter</param>
</generator>
</id>
<one-to-one name="Matter" class="cdl.impl.MatterImpl" constrained="true"/>
<bag name="Property" inverse="true" lazy ="false">
<key column="XMLID" />
<one-to-many class="cdl.impl.PropertyImpl" />
</bag>
</class>
Property:
Code:
<class name="cdl.impl.PropertyImpl" table="Property">
<id name="PropertyID" column="PropertyID" type ="java.lang.Long" unsaved-value="null">
<generator class="identity"/>
</id>
<property name="XMLID" column="XMLID" not-null="true"/>
Ok, so what we have there, is a 1-1, then another 1-1, then a 1-M.
As you can see, I do the cascade="all" at the first 1-1, but I cannot (can I?) do the cascade from there onwards. When I designed this originally, I switched the cascades on all the way through, but I started getting the null foreign key exception right at the bottom.
I tried many various things, but could never get the cascade to work all the way down. Te question is, does Hibernate support having multiple layers of Foreign key generators, including a bag (set) at the end?
This is a very unique situation for me, and I got it to work perfectly, by doing the child.setParent() way after the first cascade had saved.
As I said, just a discussion, my system works, but it would be nice to work out a way of making cascade work through multiple layers of Foreign generators. :)
-G