-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate QueryCache
PostPosted: Tue Nov 28, 2006 5:53 am 
Newbie

Joined: Tue Nov 28, 2006 5:39 am
Posts: 3
Hi,

I have two different applications using the same database. The first application is using hibernate to access the database. The second application is using the same database directly with JDBC. If the application using JDBC writes somthing into database, I do not get this changes in my hibernate application, because I am using the hibernate query cache. How can I solve this without to disable the QueryCache? Is it possible to trigger the QueryCache to be discarded or reloaded?

My configuration:
Hibernate version: 3.1.2

Postgres Database: PostgreSQL, version: 8.0.3

Any help is appreciated

scara


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 28, 2006 6:19 am 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
What Cache provider are you using? (<hibernate-configuration>...)

_________________
andresgr (--don't forget to rate)


Top
 Profile  
 
 Post subject: hibernate configuration
PostPosted: Tue Nov 28, 2006 6:42 am 
Newbie

Joined: Tue Nov 28, 2006 5:39 am
Posts: 3
I am using org.hibernate.cache.StandardQueryCache.

the configuration file is below:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://localhost/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="connection.username">postgres</property>
<property name="connection.password">postgres</property>
<property name="connection.url">jdbc:postgresql://localhost:5432/pep_dev</property>

<!-- built-in JDBC connection pool is not for production environment! disabled -->
<property name="connection.pool_size">0</property>
<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">50</property>
<property name="c3p0.timeout">1800</property>
<property name="c3p0.max_statements">50</property>
<property name="c3p0.acquire_increment">1</property>

<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>

<property name="generate_statistics">true</property>
<property name="cache.use_second_level_cache">true</property>
<property name="cache.use_query_cache">true</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>

<mapping resource="Dimensionen.hbm.xml" />
....
</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 28, 2006 6:49 am 
Regular
Regular

Joined: Tue May 16, 2006 3:32 am
Posts: 117
"Queries are not cached in the query cache, unless you explicitly call Query.setCacheable(true), even when the query cache is enabled."


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 28, 2006 6:52 am 
Regular
Regular

Joined: Tue May 16, 2006 3:32 am
Posts: 117
"If the query should force a refresh of its query cache region, you should call Query.setCacheMode(CacheMode.REFRESH). This is particularly useful in cases where underlying data may have been updated via a separate process (i.e., not modified through Hibernate) and allows the application to selectively refresh particular query result sets. This is a more efficient alternative to eviction of a query cache region via SessionFactory.evictQueries(). " - Hibernate reference doc.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 28, 2006 6:55 am 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
Your are using EhCache

(
<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property> )

From the EHCache documentation (http://ehcache.sourceforge.net/EhcacheU ... id.s13.1.1):

Expiry Strategy

One thread per cache is used to remove expired elements. The optional attribute diskExpiryThreadIntervalSeconds sets the interval between runs of the expiry thread. Warning: setting this to a low value is not recommended. It can cause excessive DiskStore locking and high cpu utilisation. The default value is 120 seconds.

So you need to configure the EHCACHE in Hibernate. This link will help you:
http://ehcache.sourceforge.net/EhcacheU ... tml#id.s15

_________________
andresgr (--don't forget to rate)


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