We have a strange problem we can't seem to understand.
We have two entities and the one has a collections of the other. We are trying to make a duplicate of this and want to save that duplicate. However, it seems Hibernate remembers some reference to the old collection and removes all items from the original object upon saving the new one. We have been looking with a debugger and it seems all objects are different then the original ones.
We are making the duplicate by initializing all objects in collections (so no lazy loading). After that we serialize and deserialize our object tree and nullify all variables inside the instances which are annotated by @Id. Thus we were hoping to complete seperate the original and the duplicate.
We have created
a sample maven project which shows the problem.
I hope someone can enlight us a little bit. ;)