Hi everybody,
I have a class which uses a mapped composite identifier:
Code:
<class name="org.checkdisc.scan.SEFile" table="FILES">
<composite-id class="org.checkdisc.scan.FileIdentifier" mapped="true">
<key-many-to-one name="filename" class="org.checkdisc.scan.Filename"/>
<key-property name="lastModified" type="timestamp"/>
</composite-id>
...
</class>
My problem is that when I save() a new instance of SEFile, of which the "Filename" of the identifier is not yet persistent, I want the instance of Filename to be made persistent as well (before the SEFile itself is made persistent, the other way around it wouldn't work because of the foreign key constraint). Usually I would achieve this with cascade="create", but this parameter is not available for key-many-to-one. (I guess this is one of the limitations mentioned in the FAQ/Advanced Problems?)
A usual workaround is to replace the key-many-to-one with a key-property and add another many-to-one outside the composite-id (and add the cascade-option there), but I can't see how this could work because the key-property is not a simple type but a class (Filename)? The Filename mapping looks like this:
Code:
<class name="org.checkdisc.scan.Filename" table="FILENAMES">
<id name="id">
<generator class="native"/>
</id>
<property name="filename"/>
</class>
Any ideas how to achieve the cascading create? I'm using Hibernate 3.2.2. Thanks in advance!
Kevin