at com.hsp.view.TestMain.main (TestMain.java: 28)
Caused by: org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_classis not gaven, please either disable second level cache or set correct region factory class name to property hibernate.cache.region.factory_class (and make sure ; the second level cache provider, hibernate-infinispan, for example, available in the classpath).
at org.hibernate.cache.internal.NoCachingRegionFactory.buildEntityRegion (NoCachingRegionFactory.java: 69)
at org.hibernate.internal.SessionFactoryImpl.
at org.hibernate.cfg.Configuration.buildSessionFactory (Configuration.java: 1740)
at org.hibernate.cfg.Configuration.buildSessionFactory (Configuration.java: 1778)
at com.hsp.util.HibernateUtil.
... 1 more
hibernate.cfg.xml as follows:
org.hibernate.dialect.Oracle9Dialect
jdbc: oracle: thin: @ 127.0.0.1:1521: orcl
oracle.jdbc.driver.OracleDriver
myoralce
I found org.hibernate.cache.internal package does not EhCacheProvider this class, is the reason causing the problem ? There needs to be configured ehcache.xml file it, I did not configure .
------ Solution ---------------------------------------- ----
changed
------ For reference only ---------------------------------- -----
tried , the error is still the same . org.hibernate.cache.EhCacheRegionFactory class bag did not , I would package seems to have problems
------ For reference only ---------------- -----------------------
hibernate4.x modified after this , but the documentation that comes with the configuration file is not correct , I started to have encountered to this problem.
changed :
------ For reference only --- ------------------------------------
test is successful ! Thank you !
------ For reference only -------------------------------------- -
modified after the test is successful , but why should this change it ? Default settings and 4.1 documents which are
------ For reference only - -------------------------------------
true -> I put a commented out , seems to have no problem, do not know where I am with the wrong ?
other code is as follows:
@ Entity
@ Cache (usage = CacheConcurrencyStrategy.READ_WRITE)
public class Student {......
/ / junit4 test code is as follows
@ Test
public void testCache2 () {
Session ss = HibernateUtil.getSession ();
ss.beginTransaction ();
Student s = (Student) ss.load (Student.class, 2);
System.out.println (s.getName ());
ss.getTransaction (). commit ();
Session ss2 = HibernateUtil.getSession ();
ss2.beginTransaction ();
Student s2 = (Student) ss2.load (Student.class, 2);
System.out.println (s2.getName ());
ss2.getTransaction (). commit ();
}
没有评论:
发表评论