-->
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.  [ 6 posts ] 
Author Message
 Post subject: load() succeeds on delete()'d object if using proxy?
PostPosted: Tue Feb 03, 2004 12:00 pm 
Newbie

Joined: Mon Dec 29, 2003 11:58 am
Posts: 3
I'd appreciate any ideas on this...

If I delete an object as follows:

session.delete( facility );
session.flush(); //not sure if this is necessary?
tx.commit();

then later attempt to load this object using:

session.load( Facility.class, facilityID );

The deleted object is found and loaded, instead of throwing a ObjectNotFoundException.

Note that this only happens if I specify a proxy for the Facility class. It fails properly with no proxy.

Also note that a session.find( 'from Facility f where f.facilityID = ?" ...) properly returns an empty set for that facility ID with or without a proxy.

I tried to evict() the object from the cache before delete()ing it, but this did not make a difference.

Is this a known bug or am I missing a step? Any ideas?

Thanks!
Michael.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 12:25 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is expected, a lazy loading won't touch the DB unless it's needed. So inside a session, it has no way to know if the object has been deleted in another one.
Loading a non proxied object or doing find() will actually load the object and touch the dB.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: still expected if delete() and load() in same open session?
PostPosted: Tue Feb 03, 2004 12:56 pm 
Newbie

Joined: Mon Dec 29, 2003 11:58 am
Posts: 3
Thanks for the info. I'll stick to using find().

What led me to believe that it was not correct behavior is that both the delete() and the load() were happening within the same open session with a disconnect() and reconnect() occuring in between.

I'll do some more experimenting to validate this.

thanks!
michael.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 2:08 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You could also use get()


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 2:47 pm 
Newbie

Joined: Mon Dec 29, 2003 11:58 am
Posts: 3
I don't see a get() method in Session?

I do use a get(0) on the returned List object from the session.find(). This definitely works, albeit a bit more cumbersome than my original load() was.

Is there a more straightforward get() method somewhere that ensures a database check?

thanks,
Michael.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 3:22 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hibernate 2.1 adds Session.get()


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