-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate to ignore the Objects that were deleted elsewhere?
PostPosted: Mon Nov 17, 2003 4:34 am 
Newbie

Joined: Tue Oct 21, 2003 3:00 am
Posts: 11
The problem happens when I have two clients running against a single database. Suppose the database only has one table and two rows:

TABLE
--------
ROW 1
ROW 2

Both client loaded same set of data. After client 1 deleted "ROW 1", client 2 then updates "ROW 2" and attempt to save. As a result I get an "Row not found" exception.

I guess my question is how do I get Hibernate to ignore that "ROW 1" was deleted by someone else and don't throw the exception?

I have looked into the method

Code:
public void delete(Object object) throws HibernateException;
inside SessionImpl class and noticed the following code:

Code:
if ( entry.status==DELETED || entry.status==GONE ) {
  log.trace("object was already deleted");
  return;
}


But there is no method that allows me to change the status of an entry.
Can someone please help me with this?

Many thanks,
KC


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 5:18 am 
Regular
Regular

Joined: Mon Sep 08, 2003 4:53 am
Posts: 70
Location: Germany
Why should there be no exception thrown? Isn't it important for client 2 to see, that the row was deleted?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 6:21 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You must catch the exception and do a save.
This is fundamentaly inconsistent to update an already deleted object/row.
Hibernate manage it correctly.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 8:09 pm 
Newbie

Joined: Tue Oct 21, 2003 3:00 am
Posts: 11
andreas wrote:
Why should there be no exception thrown? Isn't it important for client 2 to see, that the row was deleted?


In our case, it is perfectly ok to ignore this problem. Having the exception thrown only breaks the flow of the software.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2003 8:12 pm 
Newbie

Joined: Tue Oct 21, 2003 3:00 am
Posts: 11
epbernard wrote:
You must catch the exception and do a save.
This is fundamentaly inconsistent to update an already deleted object/row.
Hibernate manage it correctly.


Where should I catch the exception so the flow of the system will not be borken?


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