-->
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.  [ 1 post ] 
Author Message
 Post subject: Query caching
PostPosted: Sat Feb 05, 2005 10:29 pm 
Newbie

Joined: Sat Feb 05, 2005 8:15 pm
Posts: 2
Environment Information: Not rquired

This is for general information. I spent a lot of time going through documents and forums before figuring this out. IMO the documentation should clearly mention that query caching does not work if Query.iterate() is used - Query.list() must be used.

Assuming that hibernate.cache.use_query_cache has been set to true
The query results from this snippet will NOT be cached
===================================
sess = sessionFactory.openSession();
query = sess.find("from TestHbm");
query.setCacheable(true);
for (Iterator it = query.iterate(); it.hasNext();) {
TestHbm obj =(TestHbm)it.next();
//do something to obj
}
sess.close();

The query results from this snippet will be cached
===================================
sess = sessionFactory.openSession();
query = sess.find("from TestHbm");
query.setCacheable(true);
for (Iterator it = query.list().iterator(); it.hasNext();) {
TestHbm obj =(TestHbm)it.next();
//do something to obj
}
sess.close();


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.