-->
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.  [ 15 posts ] 
Author Message
 Post subject: Caching question
PostPosted: Mon Nov 24, 2008 2:25 pm 
Newbie

Joined: Thu Nov 13, 2008 4:52 pm
Posts: 8
After caching the data needed for a request using hibernate secondary cache (ehcache) if the database is manually shutdown at any point to simulate a database down scenario, JBOSS tries to ping the database and finds that the db is unavailable and none of the requests go through although we have all the required data cached. Is there any configuration that we need to do in Hibernate which will ensure the cache is used if the database is down?


Top
 Profile  
 
 Post subject: Re: Caching question
PostPosted: Wed Nov 26, 2008 12:14 am 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
nc wrote:
After caching the data needed for a request using hibernate secondary cache (ehcache) if the database is manually shutdown at any point to simulate a database down scenario, JBOSS tries to ping the database and finds that the db is unavailable and none of the requests go through although we have all the required data cached. Is there any configuration that we need to do in Hibernate which will ensure the cache is used if the database is down?



Hibernate in theory only gets a database connection when it needs to do something with database, so you should not have a problem that way even though I think this is a little ify. What operation does exactly fail?



Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 1:44 am 
Newbie

Joined: Thu Nov 13, 2008 4:52 pm
Posts: 8
I have some associations that are cached that request is going to the database instead of reading it from the cache.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 10:57 am 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
nc wrote:
I have some associations that are cached that request is going to the database instead of reading it from the cache.



how do you fetch the associations? Do you know if the cache region's life span is long enough?




Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 4:10 pm 
Newbie

Joined: Thu Nov 13, 2008 4:52 pm
Posts: 8
<many-to-one class="com.class1" fetch="select" name="class1">
<column name="OFFER_SET_ID" precision="10" scale="0"/>
</many-to-one>
These are the kind of associations that I have. Do i need to change the fetching strategy?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 4:18 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
nc wrote:
<many-to-one class="com.class1" fetch="select" name="class1">
<column name="OFFER_SET_ID" precision="10" scale="0"/>
</many-to-one>
These are the kind of associations that I have. Do i need to change the fetching strategy?



No actually select fetching is a better idea here if you ask me. Is com.class1 cached too? what is the cache configuration for its caching region?



Farzad=


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 4:32 pm 
Newbie

Joined: Thu Nov 13, 2008 4:52 pm
Posts: 8
the class is also cached and it has read-write cache enabled.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 4:32 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
nc wrote:
the class is also cached and it has read-write cache enabled.


how about the cache configuration?



Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 4:36 pm 
Newbie

Joined: Thu Nov 13, 2008 4:52 pm
Posts: 8
i have ehcache enabled and the entries are all eternal..


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 4:42 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
nc wrote:
i have ehcache enabled and the entries are all eternal..



so far everything you did looks good. Explain to me how you fetch the association. May be we can find something there.


Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 4:45 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
farzad wrote:
nc wrote:
i have ehcache enabled and the entries are all eternal..



so far everything you did looks good. Explain to me how you fetch the association. May be we can find something there.


Farzad-



And by the way, have you setup updateTimeStmaps cache region? Do you know if any instance of this specific class has been updated at some point? That will invalidate the whole cached instances that are cached before the last update.




Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 5:06 pm 
Newbie

Joined: Thu Nov 13, 2008 4:52 pm
Posts: 8
I do have that setup but I dont think any entries have been updated..I did not understand what you meant by fetching associations.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 5:09 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
nc wrote:
I do have that setup but I dont think any entries have been updated..I did not understand what you meant by fetching associations.



Then set it up because hibernate will be confused as to how fresh cached objects are if the updatetimestamp cache region has a shorter life span than the rest of the entities. If possible, it is recommended that this region is eternal too. However, see the documentation for the correct region name.

As for the fetching, I want to know where in your code the association is requested, and what triggers hibernate's load action.



Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 5:15 pm 
Newbie

Joined: Thu Nov 13, 2008 4:52 pm
Posts: 8
I have lazy loading set to false and when I load an object all the associations are loaded..directly although I dont use the association right away. I will set up the updateTimestamps cache so thats eternal for testing..


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 08, 2008 5:27 pm 
Newbie

Joined: Thu Nov 13, 2008 4:52 pm
Posts: 8
I still have the same problems...any suggestions?


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