We have a large number of reference data tables that are used to populate drop down lists on our UI. At the moment Hibernate is executing a query against the database for every display request for every reference table. I would like to enable second level caching for these tables to improve performance.
I have enabled second level caching using EHCache as shown below but the find all queries are never hitting the second level cache. They do seem to be populating the cache but never using it. Can anyone suggest what sort of query I could use to ensure that the second level cache is checked for results?
Hibernate version:
3.2.6
Mapping documents:
Code:
<property name="hibernate.cache.provider_class">
net.sf.ehcache.hibernate.EhCacheProvider
</property>
Code:
<class-cache class="package.ClassName" usage="read-only"/>
Code:
<cache name="package.ClassName"
maxElementsInMemory="300"
eternal="true"
overflowToDisk="false"
/>
Code between sessionFactory.openSession() and session.close():Code:
return getSession().createQuery("from " + getPersistentClass().getName()).list();
Full stack trace of any exception that occurs:
N/A
Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):
N/A
Debug level Hibernate log excerpt:
N/A