Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0.5
My first post....couldn't get closure on this by searching the forums or flipping through my trusty Hibernate In Action.
Here's our scenario that we can not seem to figure out. When we retrieve an object (call it P1), we use an interceptor to clone it (standard implementation of writing/reading to stream) creating P2. That way, any changes we make to the object (P2) are not candidates for flushing. Based on business logic, we may decide to not persist any changes to that object (P2). However, we still want to commit the transaction to persist other items.
Given this approach, P1 is still in the Hibernate Session. When we persist P2, we use the session.merge(P2) method. Without doing that, we would get a NonUniqueObjectException. But with calling merge, we are always seeing unexpected updates to the database (at flush time) even when we change nothing on P2. So P1 state and P2 state are the same. It looked like the merge operation was setting the Collections to dirty? Could that be because we blindly serialized everything?
Would circumstances been different if we detached instead of cloning? Suppose, we detached, and the reattached (using session.lock), would the merge call even be needed?
Thanks in advance Hibernate community.