This is interesting... all the info are below.
Briefly here's what's happening. I'm looking up a SystemConstant object by name. All that works file. I decided to put ehcache to work. Configuring ehcache was very smooth and I was happy to see that the cache was hit but then I paid more attention when I changed the value for systemConstant object and on the second call at 1 minute apart the new value was showing... Is this a missconfiguration issue ?
Hibernate version: 3.1.3
Debug level Hibernate log excerpt:
Code:
->first call
2006-04-30 14:07:55,156 DEBUG org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:346) - select systemcons0_.id as id14_, systemcons0_.name as name14_, systemcons0_.type as type14_, systemcons0_.class as class14_, systemcons0_.description as descript5_14_, systemcons0_.value as value14_, systemcons0_.display_order as display7_14_, systemcons0_.date_created as date8_14_, systemcons0_.date_modified as date9_14_, systemcons0_.created_by as created10_14_, systemcons0_.modified_by as modified11_14_, systemcons0_.version as version14_ from public.system_constant systemcons0_ where (name=? )
2006-04-30 14:07:55,203 DEBUG org.hibernate.cache.ReadWriteCache.put(ReadWriteCache.java:148) - Caching: domain.SystemConstant#1
2006-04-30 14:07:55,203 DEBUG org.hibernate.cache.EhCache.get(EhCache.java:104) - key: domain.SystemConstant#1
2006-04-30 14:07:55,203 DEBUG org.hibernate.cache.ReadWriteCache.put(ReadWriteCache.java:169) - Item was already cached: domain.SystemConstant#1
->second call, 1 minute apart...( here I change manually the value for SystemConstant#1 and the change is reflected right away when the following code is complete - this is not expected....
2006-04-30 14:09:20,515 DEBUG org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:346) - select systemcons0_.id as id14_, systemcons0_.name as name14_, systemcons0_.type as type14_, systemcons0_.class as class14_, systemcons0_.description as descript5_14_, systemcons0_.value as value14_, systemcons0_.display_order as display7_14_, systemcons0_.date_created as date8_14_, systemcons0_.date_modified as date9_14_, systemcons0_.created_by as created10_14_, systemcons0_.modified_by as modified11_14_, systemcons0_.version as version14_ from public.system_constant systemcons0_ where (name=? )
2006-04-30 14:09:20,531 DEBUG org.hibernate.cache.ReadWriteCache.put(ReadWriteCache.java:148) - Caching: domain.SystemConstant#1
2006-04-30 14:09:20,546 DEBUG org.hibernate.cache.EhCache.get(EhCache.java:104) - key: domain.SystemConstant#1
2006-04-30 14:09:20,562 DEBUG org.hibernate.cache.ReadWriteCache.put(ReadWriteCache.java:169) - Item was already cached: domain.SystemConstant#1
EhCache.xmlCode:
<ehcache>
<diskStore path="java.io.tmpdir" />
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="1200"
timeToLiveSeconds="1200"
overflowToDisk="true"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="1200"
/>
<cache name="domain.SystemConstant"
maxElementsInMemory="25"
eternal="false"
timeToIdleSeconds="7200"
timeToLiveSeconds="7200"
overflowToDisk="false"
/>
</ehcache>