One of our tests produced the situation in the attached testcase Test.java. It's
important that em's persistence context is cleared after the first transaction.
The merge operation in the second transaction is cascaded the "new" insurance
instance, which actually produces the following exception at commit:
Exception in thread "main" javax.persistence.RollbackException: Exception
[TOPLINK-7231] (Oracle TopLink Essentials - 2006.8 (Build 060822)):
Exception Description: Cannot persist detached object [company.Insurance@1cdfd19].
Class> company.Insurance Primary Key> 
My preliminary analysis is as follows:
The offending line is in
When determinating "new" objects in this UnitOfWork, TopLink iterates the object
graph. Finding the "unknown" insurance, it tries to register it as new object.
This fails in
because it's already in the global cache. I don't understand the complete
situation, but the assumption that "unknown" objects encountered in the object
graph traversal are always "new" looks like a bug to me.