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]