-->
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: Concurrent delete on same row exception
PostPosted: Thu Oct 21, 2004 8:22 am 
Newbie

Joined: Thu Oct 21, 2004 8:13 am
Posts: 8
Hibernate version : latest

hello there,
i am writing code to ensure that when 2 users are deleting the same record at the same time, i want to be able to make sure that the second delete of the same record, which will definitely fail (cos the first delete will pass) is handled properly. I have tried LockMode.upgrade to prevent the second thread from getting a read on the same row that the first thread is deleting but the second thread still does, so that method is not working, i have also thought of catching any specific hibernateexception or jdbcexception(which gives the error code) which might indicate that the row the thread is trying to delete does not exist. but all i got was a generic hibernateexception which could mean anything. i also tried calling getCause() method hoping to get a more specific exception, but i got null instead. i am now out of options, is there anyone out there who have faced a similar situation and have found a clean solution to it using hibernate or another technique? Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 21, 2004 12:15 pm 
Regular
Regular

Joined: Wed Jan 07, 2004 5:16 pm
Posts: 65
Location: CA, USA
Try using instanceof to check whether the HIbernateException you catch is an instanceof StaleObjectStateException - this exception subclass of HibernateException will be thrown if you attempt to delete a managed object that has already been deleted.

Kevin Hooke


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.