-->
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: Calling a session.get() after session.delete() fails.
PostPosted: Sun Oct 17, 2004 4:18 am 
Newbie

Joined: Thu Feb 26, 2004 4:31 am
Posts: 3
Hi...

How do I detect object is no longer available after a session.delete() has been performed?

I tried doing something like this

String jid=.....;
Object obj;
boolean deleted = false;
obj = (JobState) session.get(JobState.class, jid);
if (obj != null) {
session.delete(obj);
}

//THIS CODE FAILS
obj = (JobState) session.get(JobState.class, jid);


However, that last line, instead of returning me a "null", throws an ObjectDeletedException.

The reason for this is that I have a job scheduling code, which unschedules a job by deleting it. Within the same transaction after deleting, I would like to insert a new object (new job details) with the same PK to effectively recreate the job.

jid is assigned and is not an auto-generated PK.


Thanks a heap..

Regards
Kenneth

------------------------------------------------


Hibernate version: 2.1.6
Mapping documents:
Code between sessionFactory.openSession() and session.close():




Full stack trace of any exception that occurs:

net.sf.hibernate.ObjectDeletedException: The object with that id was deleted: IXBCAST:105




Name and version of the database you are using: Firebird 1.5

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


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.