-->
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() session.get() throws ObjectDeletedException
PostPosted: Fri Jul 08, 2005 5:30 am 
Newbie

Joined: Fri Jul 08, 2005 5:00 am
Posts: 2
This issue has been posted here at least twice before without replies:

but I'm trying my luck nevertheless since I believe there must be an answer to this.

The problem:
In the same session, do:
Code:
  session.delete(somePersistentObject);
  session.get(SomePersistentObject.class, somePersistentObjectId);
and you will get an
Code:
ObjectDeletedException: The object with that id was deleted

Which is not what you would expect by the contract of session.get() which says that no exception will be thrown if the object to be retrieved does not exist.

What happens is that the object still exists attached to the session but may not be returned by Hibernate since it is flagged as deleted. This is absolutely correct behaviour. However, instead of just returning null, the above mentioned exception is raised.

All comments why this behaviour may be a good thing, pointers to an explanation of this etc. are greatly appreciated.

Regards,

Martin Dirichs.

Hibernate version:
2.1, 3.0 and 3.1 all show this behaviour

Full stack trace of any exception that occurs:
Code:
11:21:09,673 INFO  [DefaultLoadEventListener] Error performing load command
org.hibernate.ObjectDeletedException: The object with that id was deleted: [SomePersistentObject#2c9f828f04f5bf510104f5bf91cf0020]
   at org.hibernate.event.def.DefaultLoadEventListener.throwObjectDeletedIfNecessary(DefaultLoadEventListener.java:401)
   at org.hibernate.event.def.DefaultLoadEventListener.loadFromSessionCache(DefaultLoadEventListener.java:391)
   at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:296)
   at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
   at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:167)
   at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
   at org.hibernate.impl.SessionImpl.get(SessionImpl.java:621)
   at org.hibernate.impl.SessionImpl.get(SessionImpl.java:614)
...


Debug level Hibernate log excerpt:
Code:
11:23:47,190 DEBUG [DefaultDeleteEventListener.onDelete] deleting a persistent instance
11:23:47,190 DEBUG [DefaultDeleteEventListener.deleteEntity] deleting [SomePersistentObject#2c9f828f04f5c18b0104f5c1f9610021]
11:23:47,190 DEBUG [SessionImpl.setCacheMode] setting cache mode to: GET
11:23:47,190 DEBUG [SessionImpl.setCacheMode] setting cache mode to: NORMAL
11:23:47,200 DEBUG [SessionImpl.setCacheMode] setting cache mode to: GET
11:23:47,200 DEBUG [SessionImpl.setCacheMode] setting cache mode to: NORMAL
11:23:47,200 DEBUG [DefaultLoadEventListener.proxyOrLoad] loading entity: [SomePersistentObject#2c9f828f04f5c18b0104f5c1f9610021]
11:23:47,200 DEBUG [DefaultLoadEventListener.doLoad] attempting to resolve: [SomePersistentObject#2c9f828f04f5c18b0104f5c1f9610021]
11:23:47,200 INFO  [DefaultLoadEventListener.onLoad] Error performing load command


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.