We have some code which adds new objects somewhere down in the object graph. We used to rely on cascade to save the object graph, saving any new objects that were added.
Recently, we added caching, so we had to change our hibernate interaction to merge things, because we were dealing with detached objects.
merge cascade does not work with a mixture of detached/persistent and transient/unsaved objects. We looked into the code of the merge cascade in hibernate 3.0 (and 3.2) and saw that it is making a copy of objects, with their ID.
What happens for us is that it does this even though ID of the new child object is null, hibernate makes a copy and sets the ID (which is null). I assume that hibernate later uses this ID to properly get the object information.
But the end result for us is that hibernate hits the "copyCache" for our new object and gets a copy which has all properties set to null.
Could hibernate be patched to make a copy of the object instead of a new instance with only the ID? What is the semantics of merge? Is cascade-merging an object with newly added children considered a "no-no"?
thanks
|