After my queries(lookups) get cached session closes, in a new session, hibernate is evicting everything after I change the DB through a random write Sql Query, how can I stop that from happening ? I’m looking into creating policies for things that rarely change.
INFO Executing [namedSqlQuery=dao.web_login, objs=[user1]]
DEBUG org.springframework.orm.hibernate3.SessionFactoryUtils user1- Opening Hibernate Session
DEBUG org.hibernate.impl.SessionImpl user1 - opened session at timestamp: 5511432318976000
DEBUG org.hibernate.impl.SessionFactoryImpl user1- evicting second-level cache: USERS_LOOKUP
DEBUG org.hibernate.impl.SessionFactoryImpl user1- evicting second-level cache: COUNTRY_LOOKUP
ecache.xml
<cache name="query.oneHourPolicy"
maxElementsInMemory="10000"
eternal="false"
timeToLiveSeconds="3600"
diskPersistent="true"
overflowToDisk="true"/>
spring hibernate configuration
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">ehcache.xml</prop>
found the Hibernate Issue https://hibernate.onjira.com/browse/HHH-2224
I tested with the bellow :
in my random query
whenever I call the above and it’s a DB change it will invalidate only the cache syncronized by table = USER or USER_ADDRESS
and only syncronized random read queries or entities will be evicted