日期:2014-05-17  浏览次数:20700 次

hibernate3.2无法启动2级缓存

 
XML code
<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>


在相应的bean.hbm.xml也有 <cache usage="read-only"/> 

Java code

在执行 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


 

<property name="hibernate.cache.use_second_level_cache">false </property> 
  <property name="hibernate.cache.use_query_cache">false </property> 
必须把这俩个设置为false就能正常运行 可我又必须要2级缓存 么办 
我用的hibernate3.2



------解决方案--------------------
帮顶。