-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Session.merge and deleted Objects
PostPosted: Thu Jul 07, 2005 8:09 pm 
Newbie

Joined: Thu Mar 17, 2005 1:55 pm
Posts: 15
What's the rationale for NOT throwing ObjectDeletedException (or StaleObjectException) when you pass an object with an identifier that was deleted in a previous transaction to Session.merge()?

Just think about the usual CRUD interface: User 1 loads the object for modifications; User 2 deletes the object; User 1 saves the modifications (thru Session.merge). Now, instead of getting an exception, the object will be recreated. This is not desirable -- there was a concurrent modification, and User 1 should get a StaleObjectException or a ObjectDeletedException (not sure about which one is more appropriate -- my vote would go for the latter).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 07, 2005 8:15 pm 
Newbie

Joined: Thu Mar 17, 2005 1:55 pm
Posts: 15
The javadoc for the merge operation says it's semantics are defined by JSR-220, which says:

"If X is a removed entity instance, an IllegalArgumentException will be thrown by the merge operation (or the transaction commit will fail)."

While I won't argue about the stupidness of throwing IAE instead of defining a more specific exception, the (unfinished, I know) specification makes it clear that calling merge() on deleted instances must fail, and not recreate the instance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.