-->
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.  [ 4 posts ] 
Author Message
 Post subject: saveOrUpdate does not throw an exception when update fails
PostPosted: Thu Sep 30, 2010 3:01 pm 
Newbie

Joined: Thu Sep 30, 2010 12:52 pm
Posts: 2
Hello,

I have the following situation:
- there is a record in the db
- the code reads the record and obtains the ID
- the record is deleted by some other user
- I try to update the record with saveOrUpdate()
- Hibernate generates an update SQL statement
- the record, which does not exists at this time point, is not updated and there is no exception

Is it an expected behavior? How do I verify that operation has been sucessfull without reading the database?
Thanks for help!


Top
 Profile  
 
 Post subject: Re: saveOrUpdate does not throw an exception when update fails
PostPosted: Thu Sep 30, 2010 10:13 pm 
Beginner
Beginner

Joined: Fri Mar 11, 2005 7:46 am
Posts: 29
Hi greg - your update does not fail - there are no matching rows - it is very different.

Have a look here -
http://docs.jboss.org/hibernate/core/3. ... state.html


Top
 Profile  
 
 Post subject: Re: saveOrUpdate does not throw an exception when update fails
PostPosted: Fri Oct 01, 2010 10:09 am 
Newbie

Joined: Thu Sep 30, 2010 12:52 pm
Posts: 2
Kostaky,
thank you. I hoped that Hibernate would check for number of affected records which is 0 in this case. Is there a way to check for number of affected rows in Hibernate?

Thanks.


Top
 Profile  
 
 Post subject: Re: saveOrUpdate does not throw an exception when update fails
PostPosted: Fri Oct 01, 2010 11:41 am 
Beginner
Beginner

Joined: Fri Nov 14, 2008 7:34 pm
Posts: 24
use @version and you'll get exception


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.