I am in the process of upgrading Hibernate from version 2.1.6 to 3.0.5. Hibernate 3 Migration Guide says to replace saveOrUpdateCopy with merge. But by doing so many of my test cases fail with following kind of stack trace. When I replace the merge() method with saveOrUpdate(), everything works fine. Is there any problem with merge or is there a problem with the way it has been used in my application?
Code:
<testcase classname="com.abc.service.product.cases.InventoryTests" name="testMultipleInventory" time="0.321">
<error type="java.lang.UnsupportedOperationException">java.lang.UnsupportedOperationException at java.util.AbstractList.remove(AbstractList.java:171) at java.util.AbstractList$Itr.remove(AbstractList.java:436) at java.util.AbstractList.removeRange(AbstractList.java:661) at java.util.AbstractList.clear(AbstractList.java:257) at org.hibernate.collection.PersistentIdentifierBag.clear(PersistentIdentifierBag.java:90) at org.hibernate.type.CollectionType.replaceElements(CollectionType.java:393) at org.hibernate.type.CollectionType.replace(CollectionType.java:426) at org.hibernate.type.TypeFactory.replace(TypeFactory.java:385) at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:239) at org.hibernate.event.def.DefaultMergeEventListener.entityIsPersistent(DefaultMergeEventListener.java:125) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:106) at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:54) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:535) at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:539) at com.abc.service.product.ABCProductTestCase.prepareConfigurableEntities(ABCProductTestCase.java:191) at com.abc.ABCAbstractTestCase.onSetUpInTransaction(ABCAbstractTestCase.java:126) at org.springframework.test.AbstractTransactionalSpringContextTests.onSetUp(AbstractTransactionalSpringContextTests.java:93) at org.springframework.test.AbstractDependencyInjectionSpringContextTests.setUp(AbstractDependencyInjectionSpringContextTests.java:123)</error>
</testcase>