Hi,
I have a hibernate object containing a collection(set) of child objects. Both the object and the collection are cached(second-level cache). I would like to evict the object as well as its collection from cache.
I tried out the evict() method on the object but it did NOT evict the collection. It only evicted the parent object. I have cascade="all-delete-orphan" on the collection. Is this the expected behaviour? I however had read the following in Hibernate documentation:
Quote:
Hibernate will evict associated entities automatically if the association is mapped with cascade="all" or cascade="
all-delete-orphan".
Now, suppose i use the evictCollection(String roleName) method to evict the collection.
What should the 'roleName' that i should pass to this method? I have the following hbm:
Code:
<hibernate-mapping>
<class
name=[b]"com.abc.Parent"[/b]
table="CR_PROCESSING_ENGINE"
discriminator-value="-1"
>
[b]<cache usage="transactional"/>[/b]
<composite-id name="id" class="com.abc.ParentId">
<key-property
name="id"
column="ID"
>
</key-property>
<key-property
name="versionId"
column="VERSION_ID"
>
</key-property>
</composite-id>
<set
name=[b]"children"[/b]
lazy="false"
inverse="true"
[b]cascade="all-delete-orphan"[/b]
>
[b]<cache usage="transactional"/>[/b]
<key
>
<column
name="ID"
/>
<column
name="VERSION_ID"
/>
</key>
<one-to-many
class="com.abc.Child"
/>
</set>
</hibernate-mapping>
Thank you.