Thank for your replay kgignatyev,
On country map file we have:
Code:
<hibernate-mapping>
<class name="com.schinvest.lra.domain.Country" table="lra_country" catalog="lra">
<!-- This table is used for read only purpose-->
<cache usage="read-only"/>
....
</class>
</hibernate-mapping>
on the ehcache.xml file we have:
Code:
<ehcache>
<diskStore path="java.io.tmpdir"/>
<defaultCache
maxElementsInMemory="100000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
/>
<cache name="com.schinvest.lra.domain.Country"
maxElementsInMemory="300"
eternal="true"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
/>
...
</ehcache>
and on the bean sesionFactory definition (Spring) we have:
Code:
<bean id="sessionFactory"
class=
"org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref bean="dataSource"/></property>
<property name="mappingDirectoryLocations">
<value>hibernate/mapping</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.max_fetch_depth">3</prop>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key=
"hibernate.transaction.flush_before_completion">true</prop>
</props>
</property>
</bean>
so the default cache class is ehCache, if we look on the log file we detect that the country table is loaded on cache at the begining of transaction, but when it finished it load again the same table on cache for the next transaction.
We have the transaction on a for-loop, just for process smaller portions of a big backup file, but it is repetitive process, the country table where to look is the same on each iteration, so we would like to keep such information on cache.
We know we could do it BY HAND, putting the country information into a satic map attribute, nevertheless the minimum to ask for cache is precisly such can of saving effort.
On the documentaion you have linked, the cache is correlated with the sesion, so the problem is to avoid clossing the sesion after transaction in order to clear the L1-cache, but not the L2-cache, between transactions.
Thanks in advance,
David