Sooooo, I'm stuck :)
This is the code I use to clear the cache:
Code:
log.debug("clearAllCaches(), evicting queries....");
sessionFactory.evictQueries();
log.debug("clearAllCaches(), done evicting queries");
log.debug("clearAllCaches(), evicting classes....");
for( Iterator i=hibernateConfig.getClassMappings(); i.hasNext(); ){
PersistentClass iClass = (PersistentClass) i.next();
sessionFactory.evict( iClass.getMappedClass() );
}
log.debug("clearAllCaches(), done evicting classes");
I've declared the class I'm interested in caching in hibernate.cfg.xml with:
Code:
<class-cache class="nrm.clas.domain.reference.InteractionMethod" usage="read-write"/>
The list code that does the actual query looks roughly like:
Code:
Criteria criteria = createCriteria(entityClass);
LogicallyDeletable example (LogicallyDeletable) entityClass.newInstance();
example.setActive(Boolean.TRUE);
criteria.add( Example.create(example) );
criteria.addOrder( Order.asc("id") );
criteria.setCacheable(true);
return criteria.list();
But when I do the cache clear operation, it doesn't seem to work.
The log statements get output, but subsequent calls to the list method don't result in SQL queries being issued. I can only see any newly inserted rows in the DB if I restart the JVM.
Any thoughts on what I'm doing wrong?
I'm currently using the non-production hibernate Hashtable-based CacheProvider, would that make a difference to the
query cache?
We're running in a standalone Tomcat instance, so there aren't too many classloaders flying around, so I don't think that's the problem.
I didn't declare any regions when I was setting up the caching, so I figured I wouldn't need to worry about regions when writing the cache-clear operation, is that assumption incorrect?