-->
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.  [ 1 post ] 
Author Message
 Post subject: Read-write cache - how to make it work?
PostPosted: Mon Nov 02, 2009 9:14 am 
Newbie

Joined: Mon Nov 02, 2009 9:03 am
Posts: 3
Hi all,

I'm trying to configure second level cache for an entity I'm using. Since the application may change data for this entity, I tought read-write cache is the appropriate mode. I'm using ehcache as the cache vendor. I added that to the hibernate.cfg.xml file:

<class-cache class="com.firm.data.FailureRecord" usage="read-write"/>

and supplied cache configuration file:

<cache name="com.firm.data.FailureRecord" maxElementsInMemory="10000" eternal="true" overflowToDisk="false" timeToIdleSeconds="3600" timeToLiveSeconds="3600"/>

When fetching an entity for the first, the log indicate that the cache not contain the entity and it hits the db:

9891 [main] DEBUG org.hibernate.cache.EhCache - key: com.firm.data.FailureRecord#ab3bf424afdfcdb44042fdb9b96af41f
9891 [main] DEBUG org.hibernate.cache.EhCache - Element for com.firm.data.FailureRecord#ab3bf424afdfcdb44042fdb9b96af41f is null
9891 [main] DEBUG org.hibernate.loader.Loader - loading entity: [com.firm.data.FailureRecord#ab3bf424afdfcdb44042fdb9b96af41f]


The problem is that the entity not stored in the cache after loaded from db, so future access to the entity hits the db again.

Is there something I forgot to configure?


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

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.