Using Hibernate 3:
I have a Project class that has a set of Vendor classes. I've enabled second level cache (I'm using the default Hashtable cache) and that takes care of caching the project and its set of vendors each time I get them from the database. This all works great...
However, when I save a new vendor [session.save(vendor)] and call flush(), the cache for project's collection of vendors is not being cleared or updated with the new vendor that was just saved.
Code:
<class name="Project">
<cache usage="read-write"/>
<set cascade="delete"
name="vendors"
lazy="true"
inverse="true">
<cache usage="read-write"/>
<key column="PROJECT_ID" />
<one-to-many class="Vendor" />
</set>
</class>
<class name="Vendor" >
<cache usage="read-write"/>
<many-to-one name="project" cascade="none"
class="Project" not-null="true">
<column name="PROJECT_ID" />
</many-to-one>
</class>
I can call evictCollection() to remove the cache of vendors from the Project and this works, however I don't want to manually call evict every time I need to save/delete a new item in a collection on a Project. A flush() should take care of this... anyone know what I am missing? Thanks in advance!