Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Merging a detached entity which has been deleted by another transaction

843830Jun 12 2006 — edited Jun 27 2006
Can 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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 25 2006
Added on Jun 12 2006
3 comments
826 views