-->
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.  [ 7 posts ] 
Author Message
 Post subject: cacheable queries
PostPosted: Fri Nov 10, 2006 7:57 am 
Newbie

Joined: Sun Oct 29, 2006 2:27 pm
Posts: 5
Hi,

From the hibernate javadoc, I understand that setting the cacheable flag on a query controls whether or not the results are cached after the query is executed. "Hibernate in Action" views this differently - the cacheable flag is used to control both caching results after the query, and using the cache to get results during the query. However, running some tests I found that it only influences cache usage during query results retrieval. Specifically, I ran the following code
Session session = sessionFact.openSession();
Query q = session.createQuery(query);
q.setInteger("userId", user.getIx());
q.setCacheable(false);
twice by first setting the cacheable flag to true, then to false. In both cases I ran the query twice. Regardless of the value of the flag, results are cached after the query is executed. When the query was ran in cacheable mode, the second execution of the query doesn't go to the database, whereas in the other case, it does.
So my conclusion is that this flag only controls whether the cache is used for results retrieval, and has no influence on whether query results are cached after execution. Am I correct?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 10, 2006 10:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you are not correct.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 12, 2006 1:08 pm 
Newbie

Joined: Sun Oct 29, 2006 2:27 pm
Posts: 5
Thanks for being so concise and to the point.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 12, 2006 1:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
You are welcome.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 12, 2006 3:09 pm 
Newbie

Joined: Sun Oct 29, 2006 2:27 pm
Posts: 5
Any way I can also find out why I'm wrong? Anybody (else)?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 12, 2006 4:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
You are wrong because what you are saying is not true.

The query result is not cached unless setCachable(true) is set.

OF course the cache still might be filled up with the entities and collection you har makred as cachable - but the queryresult (the list of which values/entities gets returned) is *not*

Just as a I said, your are wrong in your assumption.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 3:24 am 
Newbie

Joined: Sun Oct 29, 2006 2:27 pm
Posts: 5
So it's just the caching of the result set (the identity of entities returned by the query) that's controlled by this setting, and not the entities themselves (which are subject to the regular entity cache). That makes sense.
Thanks


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