Question

I have used ehcache in my application. I deploy my application in jbossAS7 server. I want to disable second level cache now. I have removed the cache properties from my hibernate configuration file, deleted my ehcache.xml file, removed the cache usage from all the hbm files. When I deploy my project in jboss, I can see that the second level cache is enabled.

[org.hibernate.cfg.SettingsFactory] (MSC service thread 1-6) Second-level cache: enabled

How do I disable it?

Was it helpful?

Solution 2

you can do this sessionFactory.getCache().evict(..); and else you can follow this link, which will explain you everything and tell you how to do it

http://jaitechwriteups.blogspot.com/2006/08/evict-collection-from-hibernate-second.html

OTHER TIPS

Encountered a similar problem. Posting the answer here for anyone who reaches this thread.

In your hibernate.cfg.xml file, set the following property to false

<property name="hibernate.cache.use_second_level_cache">false</property>

Note: commenting out this property will throw an application error if there are still annotations in your class files (or <cache> tags in hbm xml files)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top