Hi all,
I'm trying to configure second level cache for an entity I'm using. Since the application may change data for this entity, I tought read-write cache is the appropriate mode. I'm using ehcache as the cache vendor. I added that to the hibernate.cfg.xml file:
<class-cache class="com.firm.data.FailureRecord" usage="read-write"/>
and supplied cache configuration file:
<cache name="com.firm.data.FailureRecord" maxElementsInMemory="10000" eternal="true" overflowToDisk="false" timeToIdleSeconds="3600" timeToLiveSeconds="3600"/>
When fetching an entity for the first, the log indicate that the cache not contain the entity and it hits the db:
9891 [main] DEBUG org.hibernate.cache.EhCache - key: com.firm.data.FailureRecord#ab3bf424afdfcdb44042fdb9b96af41f 9891 [main] DEBUG org.hibernate.cache.EhCache - Element for com.firm.data.FailureRecord#ab3bf424afdfcdb44042fdb9b96af41f is null 9891 [main] DEBUG org.hibernate.loader.Loader - loading entity: [com.firm.data.FailureRecord#ab3bf424afdfcdb44042fdb9b96af41f]
The problem is that the entity not stored in the cache after loaded from db, so future access to the entity hits the db again.
Is there something I forgot to configure?
|