-->
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.  [ 5 posts ] 
Author Message
 Post subject: second level caching, cache.EhCache Element NULL
PostPosted: Wed Sep 17, 2008 2:49 pm 
Newbie

Joined: Wed Oct 18, 2006 7:29 am
Posts: 11
Hello All,

I am trying to have the second level cache working using ehcache. What i see in the hibernate log output is that it adds the entry to the cache but next time it is not able to retrieve it.

Code:
engine.TwoPhaseLoad adding entity to second-level cache: [Person#254]

[30593] cache.EhCache key: Person#254
[30593] cache.EhCache Element for Person#254 is null



my ehcache looks like this

Code:
<cache name="Person" maxElementsInMemory="100" eternal="true" timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="false" />



I am not sure what might be the reason, only difference is that i am doing these in grails app, i hope that's not a problem.

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2008 3:39 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Try increasing the number of elements the cache can hold (currently, 100).
Also try setting overflowToDisk=true, just in case.

Lastly, remember that the cache will only work if you are getting your object using session.load() or session.get().

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2008 4:04 pm 
Newbie

Joined: Wed Oct 18, 2006 7:29 am
Posts: 11
thanks for the reply,

i am not sure of session.get and load only i have to use HQL as i cannot have get and load only. But i think that's not a problem as i can see the caching happening only for some case it's null.

So i assume max elements is the case i did try increasing that though.. not sure if grails is not picking up my ehcache.xml file.

Thanks


gonzao_diaz wrote:
Try increasing the number of elements the cache can hold (currently, 100).
Also try setting overflowToDisk=true, just in case.

Lastly, remember that the cache will only work if you are getting your object using session.load() or session.get().


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2008 4:16 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Quote:
not sure if grails is not picking up my ehcache.xml file.


If that were the case, you would see a message on your console output saying something like this

Cache configuration for [your class name] not found, using defaults ...

And I insist. Hibernate only uses the second level cache for session.load() kind of operations, not for the result of random queries.

You can cache queries as well, but this is only valid for queries that are run frequently and with the same parameters.[/quote]

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 17, 2008 4:52 pm 
Newbie

Joined: Wed Oct 18, 2006 7:29 am
Posts: 11
sorry i forgot to mention, i have enabled query cache as well :)
looks like its working, only thing i am trying to do is i don't want any select statements after the first query

may be i am trying too much :) thanks for the help


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.