I'm having some trouble getting cascading saves working with a map. I have a class Digest which contains a map of Query objects and number of occurance pairs. Since I am using an object a a key in the map, I used an index-many-to-many association for the map's index.
The problem arises whrn I try to save an instance of the Digest class. Nothing related to the map is saved... no Query objects and no relationship information in the Map table. Since I have cascade set to 'all', I expected a save of the Digest object to save all the objects and data int he map.
Is this a correct expectation? Everythign seems to work as I would expect if the map uses a String or Int as a key (and then not using the index-many-to-many association). Does the index-many-to-many change cascade sematics?
-mike
This is the mapping for my 'Digest' class, which contains a map of Query objects and number of times that query occured.
Code:
<?xml version="1.0"?>
<hibernate-mapping>
<class
name="no.fast.vespa.model.reporting.test.Digest"
table="Digest"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="id"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="native">
</generator>
</id>
<map
name="querys"
table="Querys"
lazy="false"
sort="unsorted"
inverse="false"
cascade="all"
>
<key
column="digest_id"
/>
<index-many-to-many
class="no.fast.vespa.model.reporting.test.Query"
column="query_id"
/>
<element
column="occurances"
type="integer"
not-null="true"
unique="false"
/>
</map>
<property
name="name"
type="java.lang.String"
update="true"
insert="true"
column="name"
not-null="true"
unique="false"
/>
</class>
</hibernate-mapping>
And this is the actual Query class
Code:
<hibernate-mapping>
<class
name="no.fast.vespa.model.reporting.test.Query"
table="Query"
dynamic-update="false"
dynamic-insert="false"
>
<id
name="id"
column="id"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="native">
</generator>
</id>
<property
name="queryTerm"
type="java.lang.String"
update="true"
insert="true"
column="queryTerm"
not-null="true"
unique="true"
/>
</class>
</hibernate-mapping>