Have been using Coherence for the Query and Second Level Cache.
I am enabling the Query cache for the StoryBean Entity using the following line of code. The results get cached and the subsequent requests are served from cache.
Criteria crit = sess.createCriteria(StoryBean.class).setCacheable(true);
The problem is that there is an update query running which updates the same table. Code is copied below. It uses a named query ( @NamedQuery(name="updateStory", query="update StoryBean as story set story.story_details = :details where story.story_id= :storyID") )
Query query = sess.getNamedQuery("updateStory"); query.setString("details",storyDesc); query.setString("storyID",storyID); query.executeUpdate();
This code executes an Update command on the Database and everything works perfectely.
Now the problem is once the Update is done, the next call to the sess.createCriteria(StoryBean.class).setCacheable(true); throws a [org.hibernate.event.def.DefaultLoadEventListener] Error performing load command: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: exception
Hibernate is trying to retrieve the details from cache and its not able to find the updated row from the cache.
Any body has come across this issue ? hibernate.cfg.xml has the following properties
<property name="hibernate.cache.provider_class">com.tangosol.coherence.hibernate.CoherenceCacheProvider</property> <!--optimizes cache access for clustered caches by increasing cache reads and decreasing cache updates.--> <property name="hibernate.cache.use_minimal_puts">true</property> <!-- Key to enable Query Cache --> <property name="hibernate.cache.use_query_cache">true</property> <!-- Key to enable L2 or Second Level Cache --> <property name="hibernate.cache.use_second_level_cache">true</property>
|