-->
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.  [ 5 posts ] 
Author Message
 Post subject: session.contains() by id
PostPosted: Thu Jul 29, 2004 2:48 pm 
Newbie

Joined: Wed Apr 07, 2004 1:32 pm
Posts: 18
I need to check if a particular object is already cached by the sesssion using it's id, Is it possible?

I need to know is the object is cache before using the get method, I don't want hibernate to go to the database.

Is there a way to query directly the cache?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 29, 2004 2:51 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
get() and load() both hit the session cache, you don't have to check this yourself.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 29, 2004 3:03 pm 
Newbie

Joined: Wed Apr 07, 2004 1:32 pm
Posts: 18
Thanks for the fast reply, but I want to be sure it's there, I don't want hibernate to go to the database if the object is not on cache.

get and load hit the cache, but if the object is not there, is goes to the database.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 29, 2004 3:04 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You only have session.contains(), but it needs an instance, not an id.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 29, 2004 3:09 pm 
Newbie

Joined: Wed Apr 07, 2004 1:32 pm
Posts: 18
Is there a way around? interacting directly with the cache or something else?


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