Ehcache hibernate second level caching, hibernate eviction automatically

After my lookups get the cached session closed, in a new session, hibernate pokes everything after I changed the database to a random Sql request for writing, how can I stop this? I am developing 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 sleep 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>
+5
source share
1 answer

found the Hibernate problem https://hibernate.onjira.com/browse/HHH-2224

I tested with the following:

in my random request

<sql-query name="random_write_query" callable="false">
        <synchronize table="USER"/>
        <synchronize table="USER_ADDRESS"/>
        {CALL PACKAGE.FUNCTION(?)}
</sql-query>

whenever I call this and this database change, it will invalidate only the cache synchronized by table = USER or USER_ADDRESS

.

<sql-query name="random_read_query">
         <synchronize table="USER"/>
         <synchronize table="USER_ADDRESS"/>
         <return-scalar column="USERNAME" type="string"/>
        <![CDATA[
            SELECT USERNAME FROM USER, USER_ADDRESS...
        ]]>
    </sql-query>
+3

All Articles