Hibernate version: 3.3.2
Our project has a parent-child class relationship defined with this mapping:
Code:
<map name="children"
lazy="false"
batch-size="30"
inverse="true"
cascade="save-update"
order-by="unique_key2 asc">
<key column="parent_primary_key" />
<map-key type="integer" formula="unique_key2" />
<one-to-many class="child_class" />
</map>
The child has a PK object consisting of the 'parent_primary_key' and 'unique_key2'.
There is an initial load of the parent and several children within the same session. The objects are eventually flushed and the session is closed.
Then, a new session is created and the following actions occur:
1. Add new child record to parent
2. Merge parent in session
3. Call session saveOrUpdate with parent
.....perform additional work on parent....
4. Merge parent in session ( _hibernateSession.merge(obj) )
5. Call session saveOrUpdate with parent
6. Flush the hibernate session
7. Explicitly evict the parent and child objects from the session
Throughout the process, the parent's child records show the new object, but the child object is still not persisted.
The child Java objects do not have a backref to the parent.
In this scenario, there is no concurrent session, so most of the solutions we've seen don't seem to apply.
The merge() step was added to help get us past the common NonUniqueObjectException.
What might we be missing?
Thanks in advance.