Tuesday, November 4, 2008

Eliminate some of ehcache warnings in Hibernate 3

When configuring Hibernate second-level cache using ehcache as cache provider, most articles (eg. Java Persistence with Hibernate) or hibernate manual tell you to use:

hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider

But this way you will get some warning log message like:
To avoid this warning consider using the CacheManager factory methods to create a singleton CacheManager or specifying a separate ehcache configuration (ehcache.xml) for each CacheManager instance.

To eliminate that, you can simply change the cache provider class to:

hibernate.cache.provider_class=net.sf.ehcache.hibernate.SingletonEhCacheProvider

Ref: http://ehcache.sourceforge.net/documentation/hibernate.html

No comments: