Merging a detached entity which has been deleted by another transaction
843830Jun 12 2006 — edited Jun 27 2006Can anyone tell me what the expected behavior of EJB3 EntityManager should be when we try to merge a detached entity which has been deleted by another transaction? I expect that it should throw the OptimisticLockException. However, I found that it silently created a new instance back in the database. I am using Hibernate EntityManager, and I am not sure whether this is a bug in Hibernate or the merge method is designed in this way.
If the merge method is really design to work in this way, I will be very disappointed because it means that the optimistic concurrency protection is completely broken here.
I have found a bug related to this problem submitted in Hibernate JIRA, but it was rejected by a responder saying that this is the expected behavior of merge.
Since Hibernate is only an implementation of EJB3 Persistence, I want to know what exactly the EJB3 standard says. Can any experts of EJB3 specification answer me this question?