-->
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: Big Problem with Caching, please help
PostPosted: Thu Jun 23, 2005 10:07 am 
Regular
Regular

Joined: Fri Feb 25, 2005 3:02 am
Posts: 71
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version:3.0[/b]

[b]Mapping documents:
Here is part of my hibernate.cfg.xml:
..................
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
............

Here is part of my customer.hbm.xml:
..............
<class
name="com.gloptv.smsc.Customer"
table="customer"
lazy="true"
dynamic-update="false"
dynamic-insert="false"
select-before-update="false"
optimistic-lock="version"
>
<cache usage="nonstrict-read-write" />
.............

here is part of my ehcache.xml placed in my classpath
.............
<cache name="org.hibernate.cache.StandardQueryCache"
maxElementsInMemory="100"
eternal="false"
timeToLiveSeconds="86400"
overflowToDisk="true"/>

<cache name="query.CustomerList"
maxElementsInMemory="100"
eternal="false"
timeToLiveSeconds="86400"
overflowToDisk="true"/>

<!-- UpdateTimestampsCache -->
<cache name="org.hibernate.cache.UpdateTimestampsCache"
maxElementsInMemory="5000"
eternal="true"
overflowToDisk="true"/>
...............
[/b]

[b]Code between sessionFactory.openSession() and session.close():
static public List getCustomerList() throws Exception
{
Session session = HibernateUtil.currentSession();
session.connection().setAutoCommit(true);
Query query = session.createQuery("FROM Customer c");
query.setCacheable(true);
query.setCacheRegion("query.CustomerList");
return query.list();
}

[/b]

[b]Full stack trace of any exception that occurs:[/b]

[b]Name and version of the database you are using:postgresql 8.0[/b]

[b]The generated SQL (show_sql=true):
select customer0_.id as id, customer0_.name as name0_, customer0_.is_deleted as is3_0_, customer0_.user_id as user4_0_ from customer customer0_

[/b]

[b]Debug level Hibernate log excerpt:[/b]

My problem is that caching is not working at all after having made all the necessary configuration. If I've missed something please let me know. Each time I call my function getCustomerList I found in my postgresql log doing a select in the database. Can anyone please help me solve my problem

thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 24, 2005 3:05 am 
Regular
Regular

Joined: Fri Feb 25, 2005 3:02 am
Posts: 71
Hi, I found what I've missed. I should add

<property name="hibernate.cache.use_query_cache">true</property>

in my hibernate.cfg.xml


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.