日期:2014-05-17 浏览次数:20700 次
<property name="hibernate.cache.provider_calss">org.hibernate.cache.EhCacheProvider</property> <property name="hibernate.cache.use_second_level_cache">true</property> <property name="hibernate.cache.use_query_cache">true</property>
在执行 Configuration cfg=new Configuration().configure(); SessionFactory sf=cfg.buildSessionFactory(); 到SessionFactory sf=cfg.buildSessionFactory(); 这句的时候就抛出异常了 18:54:04,734 WARN CacheFactory:43 - read-only cache configured for mutable class: lilong.ll.Emploee Exception in thread "main" org.hibernate.HibernateException: Could not instantiate cache implementation at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:64) at org.hibernate.impl.SessionFactoryImpl. <init>(SessionFactoryImpl.java:214) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294) at lilong.ll.testmain.main(testmain.java:15) Caused by: org.hibernate.cache.NoCachingEnabledException: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache] at org.hibernate.cache.NoCacheProvider.buildCache(NoCacheProvider.java:21) at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:61) ... 3 more