-->
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.  [ 3 posts ] 
Author Message
 Post subject: Find out if query results are from cache instead of db?
PostPosted: Thu Aug 30, 2007 2:53 pm 
Newbie

Joined: Thu Aug 30, 2007 2:51 pm
Posts: 2
Hi all,

Is there a way (programmatically) to tell if the query results are from second level cache instead of database? (of course, without looking at log)?

thanks,

Hung-


Top
 Profile  
 
 Post subject: Re: Find out if query results are from cache instead of db?
PostPosted: Thu Aug 30, 2007 5:40 pm 
Beginner
Beginner

Joined: Tue Oct 10, 2006 3:23 am
Posts: 33
Just a guess here:
By enabling the statistics you can get a lot of info, there is a good article on this there:

http://www.javalobby.org/java/forums/t19807.html

and it seems that you can do stuff like:

QueryStatistics queryStats = stats.getQueryStatistics("from Sale sale");
// total hits on cache by this query.
queryStats.getCacheHitCount();

If this is not enough I once played with overloading StandardQueryCache, look at the get method



* rate if this helps *


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 30, 2007 6:09 pm 
Newbie

Joined: Thu Aug 30, 2007 2:51 pm
Posts: 2
This is a great tip. Thank you so much.

Hung-


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