-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to know if an object is in second level cache?
PostPosted: Wed Sep 26, 2007 5:15 am 
Newbie

Joined: Fri Mar 24, 2006 1:20 pm
Posts: 7
Hello,

I have a simple problem :

given a set of identifiers [1,3,98,...], I want to write a function that returns the list of objects that exist with those identifiers in the database. I want also use the second level cache, to only query the db for the non-cached identifiers.

For example if i have the set [1,3,8,43,54]. If i know that 1 and 3 are in second level cache, i use the cache and only query the db for the rest :

select * from object where id in (8,43,54)

For that to work i must know if a particular identifier is present in the second level cache.

I cannot make something like :

Session.load(1)
Session.load(3)
Session.load(8)
Session.load(43)
Session.load(54)

because I am not sure that the identifiers exist in the DB.

And I cannot make

Session.get(1)
Session.get(3)
Session.get(8)
Session.get(43)
Session.get(54)

Because then it will make a query for each non-cached object, which is not efficient.

And i can't make

select * from object where id in (1,3,8,43,54)

because I am not using the second level cache then.

So my conclusion is that I must know if a particular identifier is present in the second level cache. Is there a way to know that?

Thx a lot for your help

Antoine


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 26, 2007 7:01 am 
Newbie

Joined: Thu Aug 25, 2005 10:04 am
Posts: 6
I don't know, if it should be the users task to interfere with the cache, but you could easily query the session cache by using the statistics API, see the last two paragraphs of:

http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#performance-sessioncache


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