-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Ehcache Problem
PostPosted: Thu Jun 22, 2006 8:37 am 
Newbie

Joined: Tue May 23, 2006 1:34 am
Posts: 19
Location: Bangalore
Hi All,
I am using Hibernate 3.1.3 with EhCache 1.2. When I am using the second level Caching, in the Caching XML file I specified the location where to create the Caching files.
At run time, it is creating the Caching files. But it is not writing the Element to the cache.

When I get's the SessionFactory Statistics, it is showing "No Puts where made to the Second Level Cache".

The code snippets are given below.

Caching entries in the Hibernate Configuration file are:

Code:
<property name="cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</property>
<property name="provider_configuration_file_resource_path">/ehcache.xml</property>
<property name="use_second_level_cache">true</property>
<property name="use_minimal_puts">true</property>
<property name="use_query_cache">true</property>
<property name="use_structured_entries">true</property>


The ehCache XML file is

Code:
<ehcache>
    <diskStore path="\...\Cache"/>
   

    <defaultCache
            maxElementsInMemory="10000"
            eternal="true"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            overflowToDisk="true"
            diskPersistent="true"
            diskExpiryThreadIntervalSeconds="120"
            memoryStoreEvictionPolicy="LRU"
    />
           
    <cache name="events.Event"
           maxElementsInMemory="10"
           eternal="true"
           overflowToDisk="true"
           timeToIdleSeconds="300"
           timeToLiveSeconds="600"
           memoryStoreEvictionPolicy="FIFO">
   
<cacheEventListenerFactory class="events.MyCacheEventListenerFactory" properties="name=Event"/>
   </cache>

</ehcache>


I made entry for ehCache in the Mapping file as:
Code:
<cache usage="nonstrict-read-write" />


When Iam persisting an Object, the Object is getting persisted. But it is not adding to the second level cache.

The logging information after persisting the Object is,

Code:
22 Jun 2006 15:37:50 -- INFO -- Statistics Commit...Statistics[start time=1150970869703,sessions opened=1,sessions closed=1,transactions=1,successful transactions=1,optimistic lock failures=0,flushes=1,connections obtained=1,statements prepared=2,statements closed=2,second level cache puts=0, second level cache hits=0,second level cache misses=0,entities loaded=0,entities updated=0,entities inserted=1,entities deleted=0,entities fetched=0,collections loaded=0,collections updated=0,collections removed=0,collections recreated=0,collections fetched=0,queries executed to database=0,query cache puts=0,query cache hits=0,query cache misses=0,max query time=0]



Can anyone help me, where I am doing the mistake?

_________________
Thanks and Regards,
Suresh Setty...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 1:00 am 
Newbie

Joined: Tue May 23, 2006 1:34 am
Posts: 19
Location: Bangalore
when in the Mapping file, if the <cache usage> is changed to other than "nonstrict-read-write", it is throwing an Exception. The Exception is:

Code:
org.hibernate.AssertionFailure: Exception releasing cache locks
   at org.hibernate.engine.ActionQueue.afterTransactionCompletion(ActionQueue.java:183)
   at org.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:419)
   at org.hibernate.jdbc.JDBCContext.afterTransactionCompletion(JDBCContext.java:209)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:119)
   at events.EventDAO.save(EventDAO.java:92)
   at events.EventManager1.main(EventManager1.java:50)
Caused by: java.lang.ClassCastException: org.hibernate.cache.ReadWriteCache$Item
   at events.EventCacheEventListener.notifyElementPut(EventCacheEventListener.java:28)
   at net.sf.ehcache.event.RegisteredEventListeners.notifyElementPut(RegisteredEventListeners.java:86)
   at net.sf.ehcache.Cache.put(Cache.java:570)
   at net.sf.ehcache.Cache.put(Cache.java:516)
   at net.sf.ehcache.hibernate.EhCache.put(EhCache.java:130)
   at net.sf.ehcache.hibernate.EhCache.update(EhCache.java:117)
   at org.hibernate.cache.ReadWriteCache.afterInsert(ReadWriteCache.java:291)
   at org.hibernate.action.EntityInsertAction.afterTransactionCompletion(EntityInsertAction.java:155)
   at org.hibernate.engine.ActionQueue.afterTransactionCompletion(ActionQueue.java:170)
   ... 5 more



The logger is showing the following

Code:
23 Jun 2006 10:09:02 -- ERROR -- an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
java.lang.ClassCastException: org.hibernate.cache.ReadWriteCache$Item
   at events.EventCacheEventListener.notifyElementPut(EventCacheEventListener.java:28)
   at net.sf.ehcache.event.RegisteredEventListeners.notifyElementPut(RegisteredEventListeners.java:86)
   at net.sf.ehcache.Cache.put(Cache.java:570)
   at net.sf.ehcache.Cache.put(Cache.java:516)
   at net.sf.ehcache.hibernate.EhCache.put(EhCache.java:130)
   at net.sf.ehcache.hibernate.EhCache.update(EhCache.java:117)
   at org.hibernate.cache.ReadWriteCache.afterInsert(ReadWriteCache.java:291)
   at org.hibernate.action.EntityInsertAction.afterTransactionCompletion(EntityInsertAction.java:155)
   at org.hibernate.engine.ActionQueue.afterTransactionCompletion(ActionQueue.java:170)
   at org.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:419)
   at org.hibernate.jdbc.JDBCContext.afterTransactionCompletion(JDBCContext.java:209)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:119)
   at events.EventDAO.save(EventDAO.java:92)
   at events.EventManager1.main(EventManager1.java:50)


Any help ? :-<

_________________
Thanks and Regards,
Suresh Setty...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.