Hi ,
a.)JBoss 5.1.0.GA
b.)Hibernate 3.3.1.GA
c.)Terracotta Server 3.5.0 Express Installation with EHCache 2.4.1
I'm using the Terracotta Server to manage my distributed Hibernate cache.Below you will find my configuration files.
I am facing a problem(a major one I would say) on a simple test such as :
a.)query and object from one node and get it cached
b.)delete that same object from a different node
c.)query that object from the initial node
The problem is that at the last query I'm still getting the object I deleted from the cache even though it has been deleted from the database.
My TTL is 320 seconds and TimeToIdle also 320 seconds.
Any help is of great use,
Thank you.
The code I'm using to perform the retrieves and deletes is :
Code:
try {
Usr instance = (Usr)this.getSession().load("Usr", id);
return instance;
} catch (RuntimeException re) {
UsrDAO.log.error("get failed", re);
throw re;
}
Code:
try {
Session sess = this.getSession();
Transaction t = sess.beginTransaction();
sess.delete(persistentInstance);
t.commit();
UsrDAO.log.debug("delete successful");
} catch (RuntimeException re) {
UsrDAO.log.error("delete failed", re);
throw re;
}
ehcache.xml & hibernate.cfg.xml below
Code:
<defaultCache
maxElementsInMemory="50"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="false"
statistics="true" >
<terracotta/>
</defaultCache>
<cache name="Usr"
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="320"
timeToLiveSeconds="320"
overflowToDisk="false">
<terracotta/>
</cache>
<cache name="Address"
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="320"
timeToLiveSeconds="320"
overflowToDisk="false">
<terracotta/>
</cache>
Code:
<session-factory>
<property name="generate_statistics">true</property>
<property name="connection.username">root</property>
<property name="connection.password">root00</property>
<property name="connection.url">jdbc:mysql://192.168.224.243:3306/sergiuTest2</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.EhCacheRegionFactory</property>
<property name="net.sf.ehcache.configurationResourceName">ehcache.xml</property>
<mapping resource="Usr.hbm.xml"></mapping>
<mapping resource="Address.hbm.xml"></mapping>
</session-factory>