-->
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: Query cache isn't persisting across instances
PostPosted: Thu May 26, 2005 10:10 am 
Newbie

Joined: Tue Mar 08, 2005 7:16 am
Posts: 8
Hi all,

First things first, we're using JDK 1.5.0_01, Oracle 9i and Hibernate 3.0.3.

We've got Hibernate configured to use 3 databases (i.e. 3 hibernate.XXX.cfg.xml) files. We're getting some odd behaviour with caching queries to 2 out of the 3 databases.

The first one works fine but when querying the other 2 the query cache is used while in memory but it doesn't appear to be persisted (i.e. written to disk) when the application ends.

For example: I've written a test case that loops over a query 5 times and dumps the results to the screen. The first time it hits the query I can see a call made to the database and data is returned. For each subsequent 4 loops, no database call is made as the results are served from the cache. Great. I then re-run the program immediately and the database is hit once again, instead of the cache created for the previous instance being used.

This seems to show that the caching mechanism we're using is failing to persist the query cache to the disk (it works in memory so we know the cache is working) when the application ends. From our config file we've got:

Code:
        <property name="hibernate.cache.provider_class">com.db.csa.cache.persistent.[b]PersistentCacheProvider[/b]</property>
        <property name="hibernate.cache.use_query_cache">true</property>


So, we should be using the PersistentCache. I'm now a little out of my depth as I'm not the person who set the caching up.

Has anyone else had anything similar with the PersistentCache implementation and the query cache? Can anyone point me in some useful directions?

Before anyone asks, yes we have enabled caching in the code:

Code:
            Query query = session.createQuery("from Bond as b where (b.ticker = ?)");
            query.setCacheable(true);
           
            query.setString(0, ticker);
           
            return query.list();


Thanks,

Rob[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2005 11:34 am 
Newbie

Joined: Tue Mar 08, 2005 7:16 am
Posts: 8
I've done some more digging and it appears that the query cache for each of the 3 configurations is overwriting the other ones and so causing the problems.

Is there any way to specify a region name for the query cache? Then we could have 3 separate query caches and so save us the hassle.

Thanks,

Rob


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.