Java – does hibernate 4 and ehcache need ehcache core library?
I tried to upgrade my hibernate 3 application to hibernate 4 The application uses ehcache
When upgrading to hibernate 4.2 0. Final I added a dependency on hibernate-ehcache-4.2 0. Final's suggestion
When I start the application, I receive the following error:
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cache/TimestampsRegion
according to http://www.javacraft.org/2012/03/migrate-to-hibernate-4-ehcache.html I should remove the dependency on ehcache core and use only the hibernate provided to resolve this error
Now, if I follow these instructions to remove this dependency, my application uses net sf. ehcache. CacheManager no longer compiles
// For example,this no-longer works CacheManager manager = CacheManager.getInstance();
So my question is, can I use these two libraries and continue to work as before (without updating the application), or do I have to change the application. In this case, hibernate ehcache even provides the functions required to access the cache?
Solution
When using hibernate 4, you must use org Hibernate packaged classes
In form 4, they directly transplanted to 4 in Hibernate repurchase (which is the wisest in our opinion)
So use org hibernate. cache. ehcache. Ehcacheregionfactory should be able to solve your problem