-->
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.  [ 3 posts ] 
Author Message
 Post subject: Delete (Un)Successful?
PostPosted: Wed Feb 23, 2005 4:07 pm 
Regular
Regular

Joined: Tue Jan 11, 2005 8:55 pm
Posts: 53
Hi,

Is there a way to verify that a call to session.delete(object) was (un) successful?

I've tried deleting an sample object with an invalid id (i.e., a random id that hasn't been used), but no exception is thrown.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 23, 2005 5:11 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
try to manually flush just after delete... but you should use this only during development, just to debug.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: delete not successful - row not found
PostPosted: Thu Mar 03, 2005 7:12 pm 
Newbie

Joined: Thu Mar 03, 2005 6:45 pm
Posts: 1
Hi, I'm having similar question about session.delete method.

I tried calling session.delete(object) and my delete statement was using primary key that does not exist in table (DB2).
Hibernate throws HiberException.
Is there a way to avoid this ? I want to see HibernateException for anything else but not for "row not found". In case of DB2, I'd like to see sqlcode=100 separated so I can handle this differently.

Can you tell me how I can get sqlcode after Hibernate throws HibernateException ? do I need to catch any other exception earlier ?

here is a snapshot of my code :
protected void delete (Object bean) {
try {
session.delete(bean);
session.flush();
} catch (HibernateException x) {
throw new PersistenceException("Error trying to delete";
} finally {closeSession();}

}

_________________
sv


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