Hello All,
I'm using Hibernate 3. I have a Party class with a Map of Capability objects using CapabilityType objects as keys. I need the map to be persisted when detached Party objects are saved (using merge() ). The mapped values all cascade perfectly (thanks!) and the keys cascade if I map them as a <composite-map-key> like this:
Code:
<map name="capabilities"
table="PARTY_CAPABILITIES"
cascade="all,delete-orphan">
<key column="OWNER_ID"/>
<composite-map-key class="CapabilityType">
<!-- This works but stores the CapabilityType information in the PARTY_CAPABILITIES table. -->
<key-property name="name" column="NAME" type="string" />
<key-property name="description" column="DESCRIPTION" type="string" />
</composite-map-key >
<one-to-many class="Capability" />
</map>
I would really like the key class to be in a separate table, however. Ideally I would use a mapping like this:
Code:
<map-key-many-to-many column="KEY_ID" class="CapabilityType" />
<!-- This stores CapabilityTypes in their own table but does not cascade. -->
But the <map-key-many-to-many> does not cascade saves. I get errors because the key has not already been saved. I'm not going to be able to save the keys separately since the objects are detached when the map is changed.
Is there a way to cascade to a <map-key-many-to-many> ?