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:
|