-->
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.  [ 4 posts ] 
Author Message
 Post subject: Hibernate Second Level Caching.
PostPosted: Thu Jun 16, 2005 2:35 pm 
Regular
Regular

Joined: Thu Apr 21, 2005 9:05 am
Posts: 50
Location: Boston, U.S
In our project we have been considering using Hibernate and Tangosol.
While i was doing my Proof of Concept, i realized that only Session.get()
requests are cached and where as in createquery request the data is not
cached.

For Instance i have made two get calls on session

session.get(xxx.class, new Integer(10));
session.get(xxx.class, new Integer(10));

In the above case only one SQL is executed and during the second
time it reads from the cache.

But if use twice

session.createQuery(" from xxx a where a.col1='10' ").list();
session.createQuery(" from xxx a where a.col1='10' ").list();

Two sql queries are getting triggered and the data does not
seem to be cached.

Any thoughts or suggestions are most welcome.

Regards

Hibernate version:
3.0.1
Mapping documents:
<!-- Second-level Cache -->
<property name="hibernate.cache.region_prefix">repl-</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_structured_entries">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.cache.provider_class">CoherenceCacheProvider</property>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 2:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Read the docs about the query cache.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 2:41 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
http://www.hibernate.org/hib_docs/v3/re ... querycache


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 3:09 pm 
Regular
Regular

Joined: Thu Apr 21, 2005 9:05 am
Posts: 50
Location: Boston, U.S
Thanks Gavin and Christine, I got it right after reading the documentation about QueryCache.

I also would like to share my reading with all the members of this forum.

"Hibernate queries always ignore cache by default"
So you got to set the following whenever you want enable caching

qry.setCacheable(true);
qry.setCacheRegion("UserQry");

Hope it helps somebody.

Regards


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