This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Dynamically change Ehcache configuration through hibernate and Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Dynamically change Ehcache configuration through hibernate and Spring" Watch "Dynamically change Ehcache configuration through hibernate and Spring" New topic
Author

Dynamically change Ehcache configuration through hibernate and Spring

N Deepu
Greenhorn

Joined: Jul 28, 2011
Posts: 25

I want to use a Second-Level chache in my code which has Spring and hibernate. I've made all the configurations in spring-persistence.xml for Ehcache configuration and the cache is working fine. My problem is that the configurations are already set by default in the ehcache-failsafe.xml. When I change the value in database and refresh the page, the changes are not reflected immediately since the timeToIdleSeconds="120" in the xml. I want to change this to 0 so that the changes are reflected immediately. I tried doing this : CacheManager manager = CacheManager.create();

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

I want to change this to 0 so that the changes are reflected immediately

Is this change for the lifetime of the application or some other combination?

SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
N Deepu
Greenhorn

Joined: Jul 28, 2011
Posts: 25

Is this change for the lifetime of the application or some other combination?


I want to retrieve the latest values from the cache when the database is updated. It is fetching the new values after 120 seconds. How do I change?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

Cross posted. Please BeForthrightWhenCrossPostingToOtherSites.

You might want to look at this for an alternate way to configure at runtime. But I haven't looked in to how/whether Hibernate support this.
 
 
subject: Dynamically change Ehcache configuration through hibernate and Spring
 
Similar Threads
Hibernate Configuration Layer Technique
Beginner needs help with second-level cache
hibernate query cache
Spring ehcache null value caching
Ehcache ...