-->
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.  [ 1 post ] 
Author Message
 Post subject: session.delete() fails, Hibernate raises ObjectDeleted Excpn
PostPosted: Wed Jan 19, 2005 8:31 am 
Newbie

Joined: Tue Jan 18, 2005 9:33 am
Posts: 3
Hibernate version:2.1.7

Even if session.delete() fails, and raises HibernateException, Hibernate marks the object as deleted

I am trying to figure out whether the StaleObjectStateException is being raised because
1. A row with the specified ID did not exist - "usr-msg: Contact System Administrator"
2. This row was updated in another session - "usr-msg - This data was updated by another user. please requery."

The Hibernate Exceptions raised is - net.sf.hibernate.ObjectDeletedException
Exception.getMessage() - The object with that id was deleted: 999109, of class: mypackage.Auditable


try
{
sess.delete(a_object);
sess.flush();
}
catch(HibernateException he)
{
if (he instanceof StaleObjectStateException)
{
Object row;
try
{
row = sess.get(a_object.getClass(), ((StaleObjectStateException)he).getIdentifier());
}
catch(HibernateException he2)
{
row = null;
}
if ( row== null)
throw new NoDataFoundException(he);
else
throw new VersionMismatchException(he);
}
}

[/b]

Thanks and Regards
Gaurav Madan


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

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.