Dear All,
I'm facing a peculiar issue with my read only app, which uses Hibernate 3.5.3 and JbossCache-3.2.5.
All the entities in my data model are versioned and have logical deletion using a field "endDate" so when ever a version is incremented the pervious version is not deleted but end dated.
I fetch the latest version using a filter with clause "endDate is null".
All my entities are to be cached as Immutable & with cache usage "read-only". This all works fine, till I try to evict a entity.
I'm using following hibernate config.
Code:
...
.....
<property name="connection.datasource">java:SybaseDB</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
<property name="dialect">org.hibernate.dialect.SybaseDialect</property>
<property name="generate_statistics">true</property>
<property name="cache.provider_class">org.hibernate.cache.jbc.JBossCacheRegionFactory</property>
<property name="cache.use_second_level_cache">true</property>
<property name="cache.use_minimal_puts">true</property>
<property name="cache.use_structured_entries">true</property>
<property name="cache.use_query_cache">true</property>
<property name="cache.region.factory_class">org.hibernate.cache.jbc.JndiMultiplexedJBossCacheRegionFactory</property>
<property name="cache.region.jbc2.cachefactory">java:CacheManager</property>
<property name="cache.region.jbc2.cfg.entity">mvcc-entity</property>
<property name="cache.region.jbc2.cfg.collection">mvcc-entity</property>
<property name="cache.region.jbc2.cfg.query">local-query</property>
...
.....
There is another application which updates my database, so I need to refresh the cache for a few entity ocassionally.
I'm using the Cache.evictXXX() API to evict the entities/collections I want to reload from database.
However, after eviction on subsequent request to get the entity, the core doesnt apply the filter and fires a sql which just uses the unique key and doesnt append the "endDate is null" condition which is enabled for the session. Due to which the sql fetches multiple rows and throws an exception causing the app to fail loading the requested entity.
And I have to restart the app, to get it working again.
Can any one point me to the right direction to what is that I'm doing wrong over here?
Thanks.