I have an issue with the session.find() method that I'm not sure how to fix. In my application, I have Object_A and Object_A_Association. They are mapped to their respective tables TABLE_A and TABLE_A_ASSOC. The mapping doc for Object_A_Association is straightforward and the mapping_doc for Object_A has an association with the Object_A_Association, i.e.:
Code:
<set name="assoc" outer-join="true" lazy="false" cascade="none">
<key column="object_a_id" />
<one-to-many class="object_a_association" />
</set>
In two separate transactions (but one unit of work), I do this:
1) session.saveOrUpdate(Object_A_Association)
2) session.find(Object_A)
After I do a find and call "object_a.getAssoc()", I get old data. After going through the hibernate docs, I realize that the session.find() retrieves object_a directly from the database, but retrieves the object_a_association from the cache. And because the saveOrUpdate persists my association into the DB and not cache, my data read is incorrect. Any suggestions on how to fix the bad read? Thanks!
-nefi[/code]