-->
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: 2nd Level cache miss = N+1 Select
PostPosted: Mon Aug 10, 2009 12:03 pm 
Newbie

Joined: Mon Aug 10, 2009 11:50 am
Posts: 1
I'm having a problem with Hibernate's 2nd level cache using ehache. I'm doing some performance testing with multiple users and everything works fine for the first several minutes, but after that, there is a cache miss for some reason and then Hibernate does a N+1 select on the entire object graph that I'm trying to pull back, which is very painful.

I have ehcache set up pretty standard I think:

Code:
<defaultCache maxElementsInMemory="5000"
      maxElementsOnDisk="20000" eternal="true" overflowToDisk="true"
      memoryStoreEvictionPolicy="LRU" />


With the hibernate config:
Code:
<property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.EhCacheProvider" />
         <property name="hibernate.cache.use_query_cache" value="true" />
         <property name="hibernate.cache.use_second_level_cache"
            value="true" />


and my entities and collections cached with the default provider:
Code:
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class MyClass extends BaseModel implements java.io.Serializable {
}


Everything works fine for awhile and they cache is being used, but then all of a sudden, without doing any system updates or inserts (reads only), ehcache says:
Code:
Memory cache hit, but element expired
and Hibernate pulls back all the graphs and collections N+1. We are using Hibernate 3.2 and ehcache 1.6.1. Increasing the size of the cache does no good. Any suggestions or ideas are appreciated.


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.