-->
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: ehcache not caching
PostPosted: Thu Apr 21, 2005 11:54 am 
Newbie

Joined: Thu Apr 21, 2005 11:34 am
Posts: 4
Hi,
I have a simple table with about 450 rows. I am trying to cache this data. But evertime I do a q.lis() (list() on a query) an sql is generated. Why is the sql genrated every time I do list ? should it not get the data from the cache instead ?
I am have enable the cache in the mapping file, and I have the ecache file as
<cache name="net.idt.bct.db.vo.BctCountryRouteLocT"
maxElementsInMemory="5000"
eternal="false"
timeToIdleSeconds="600"
timeToLiveSeconds="1200"
overflowToDisk="false"
/>

It is taking about 10 to 12 seconds to query this data which is way too long in our case. And that was the reason I turned on the caching feature in hibernate and there not improvement in the performance.
Any ideas ? Any suggestions is greatly appreciated.

Hibernate version:
Hibernate verion 2.1.7
ehcache version 0.7

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="net.idt.bct.db.vo">
<class name="BctCountryRouteLocT" table="BCT_COUNTRY_ROUTE_LOC_T" >
<cache usage="read-only" />
<id
column="COUNTRY_ROUTE_LOC_OID"
name="CountryRouteLocOid"
type="integer"
>
<generator class="vm" />
</id>
<property
column="COUNTRY"
length="60"
name="Country"
not-null="false"
type="string"
/>
<property
column="COUNTRY_CODE"
length="10"
name="CountryCode"
not-null="false"
type="string"
/>
<property
column="ROUTE_LOC"
length="60"
name="RouteLoc"
not-null="false"
type="string"
/>
</class>
</hibernate-mapping>


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

Query q = sess.createQuery("from BctCountryRouteLocT");
q.setCacheable(true);

System.out.println("STIME="+new Date());
q.list();
System.out.println("ETIME="+new Date());

System.out.println("STIME="+new Date());
q.list();
System.out.println("ETIME="+new Date());
sess.close();

Full stack trace of any exception that occurs:
No Exception

Name and version of the database you are using:
Oracle 9i

The generated SQL (show_sql=true):

select bctcountry0_.COUNTRY_ROUTE_LOC_OID as COUNTRY_1_, bctcountry0_.COUNTRY as COUNTRY, bctcountry0_.COUNTRY_CODE as COUNTRY_3_, bctcountry0_.ROUTE_LOC as ROUTE_LOC from BCT_COUNTRY_ROUTE_LOC_T bctcountry0_

Debug level Hibernate log excerpt:
11:16:02,434 WARN CacheFactory:36 - read-only cache configured for mutable: net.idt.bct.db.vo.BctCountryRouteLocT
11:16:02,483 WARN CacheFactory:36 - read-only cache configured for mutable: net.idt.bct.db.vo.BctSwitchCarrierT
11:16:04,298 DEBUG CacheManager:177 - Creating new CacheManager with default config
11:16:04,303 DEBUG CacheManager:151 - Configuring ehcache from classpath.
11:16:04,307 DEBUG Configurator:118 - Configuring ehcache from ehcache.xml found in the classpath: file:/home/gkrishna/workspace/BCT/target/classes/ehcache.xml
11:16:04,325 DEBUG MemoryStore:124 - net.idt.bct.db.vo.BctCountryRouteLocT Cache: Using SpoolingLinkedHashMap implementation
11:16:04,327 DEBUG MemoryStore:104 - initialized MemoryStore for net.idt.bct.db.vo.BctCountryRouteLocT
11:16:04,328 DEBUG MemoryStore:124 - net.idt.bct.db.vo.BctSwitchCarrierT Cache: Using SpoolingLinkedHashMap implementation
11:16:04,328 DEBUG MemoryStore:104 - initialized MemoryStore for net.idt.bct.db.vo.BctSwitchCarrierT
11:16:04,329 DEBUG CacheManager:182 - Attempting to create an existing instance. Existing instance returned.
STIME=Thu Apr 21 11:16:06 EDT 2005
11:16:06,181 DEBUG SQL:237 - select bctcountry0_.COUNTRY_ROUTE_LOC_OID as COUNTRY_1_, bctcountry0_.COUNTRY as COUNTRY, bctcountry0_.COUNTRY_CODE as COUNTRY_3_, bctcountry0_.ROUTE_LOC as ROUTE_LOC from BCT_COUNTRY_ROUTE_LOC_T bctcountry0_
ETIME=Thu Apr 21 11:16:17 EDT 2005
STIME=Thu Apr 21 11:16:17 EDT 2005
11:16:18,077 DEBUG SQL:237 - select bctcountry0_.COUNTRY_ROUTE_LOC_OID as COUNTRY_1_, bctcountry0_.COUNTRY as COUNTRY, bctcountry0_.COUNTRY_CODE as COUNTRY_3_, bctcountry0_.ROUTE_LOC as ROUTE_LOC from BCT_COUNTRY_ROUTE_LOC_T bctcountry0_
ETIME=Thu Apr 21 11:16:29 EDT 2005


Top
 Profile  
 
 Post subject: Solved the problem
PostPosted: Fri Apr 22, 2005 1:53 am 
Newbie

Joined: Thu Apr 21, 2005 11:34 am
Posts: 4
I just had to add
<property name="cache.use_query_cache">true</property>
in the hibernate.cfg.xml file


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.