Actually, it seems like I have a different issue than what I thought.
The problem seems to be that the cached child is not getting updated with the parent's info when it gets saved.
Here's a part of the mapping file that I have:
Code:
<class name="Parent" table="Parents">
<id name="id" length="32">
<generator class="UUIDIdentifierGenerator"/>
</id>
<many-to-one name="firstChild" column="firstChildId" unique="true" cascade="save-update,delete"/>
<bag name="children" cascade="save-update,delete" order-by="createdDate asc">
<key column="parentId"/>
<one-to-many class="Child"/>
</bag>
</class>
<class name="Child" table="Children">
<cache usage="read-write"/>
<id name="id">
<generator class="assigned"/>
</id>
<many-to-one name="parent" column="parentId" not-null="true" insert="false" update="false"/>
</class>
What I do is the following:
- Create a Parent.
- Create a child, add it as the firstChild, and also as part of the children's list.
- Save the Parent.
What seems to happen is the following:
- Saves the Child
- Saves the Parent.
- Updates the child with the parent ID
- Child gets cached
When I retrieve the Child then, it lacks the information about the parent. At the Java Object level, the parent is null when the child is retrieved from the cache.
I'm wondering what setting am I missing that prevents the cache from getting the newest data.
Any help is appreciated.
Thanks!
Koichi