NHibernate configuration StandardQueryCache Exception Find BUG

NHibernate   configuration  StandardQueryCache Exception  Find BUG

2013.06.02 

#region
            configuration.Cache(c => //(Cache)
            {
                c.UseQueryCache = DefaultUseQueryCache;
                c.UseMinimalPuts = true;
                c.RegionsPrefix = "Cache";
                c.DefaultExpiration = 60;//秒
                if (DefaultUseSecondLevelCache)
                {
                     c.Provider<HashtableCacheProvider>();//
                     c.QueryCache<StandardQueryCache>();//
                     //configuration.SetProperty(Environment.UseSecondLevelCache, "true");
                    // configuration.SetProperty(Environment.QueryCacheFactory, typeof(StandardQueryCacheFactory).FullName);
                }

            });
            #endregion


未处理 NHibernate.HibernateException

  Message=could not instantiate IQueryCacheFactory: NHibernate.Cache.StandardQueryCache, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
  Source=NHibernate
  StackTrace:
       在 NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary`2 properties)
       在 NHibernate.Cfg.Configuration.BuildSettings()
       在 NHibernate.Cfg.Configuration.BuildSessionFactory()
       在 Com.Zfrong.Arch.Common.Data.NH.Core.NHSessionFactoryManager.BuildSessionFactory(String key) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\Core\NHSessionFactoryManager.cs:行号 40
       在 Com.Zfrong.Arch.Common.Data.NH.Core.NHSessionFactoryManager.GetSessionFactory(String key) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\Core\NHSessionFactoryManager.cs:行号 26
       在 Com.Zfrong.Arch.Common.Data.NH.Core.NHSessionManager.GetSessionFactory(String key) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\Core\NHSessionManager.cs:行号 71
       在 Com.Zfrong.Arch.Common.Data.NH.Core.NHSessionManager.BindCurrentSession(String key, IInterceptor interceptor) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\Core\NHSessionManager.cs:行号 35
       在 Com.Zfrong.Arch.Common.Data.NH.Core.NHSessionManager.BindCurrentSession(String key) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\Core\NHSessionManager.cs:行号 28
       在 Com.Zfrong.Arch.Common.Data.NH.DatabaseImp.get_CurrentSession() 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\DatabaseImp.cs:行号 54
       在 NH.Test.test2.initData(String key, Int64 row) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\test2.cs:行号 69
       在 NH.Test.test2.Test1(Int32 i, Int32 j) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\test2.cs:行号 139
       在 NH.Test.test2.TestThead() 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\test2.cs:行号 113
       在 NH.Test.test2.Main(String[] args) 位置 F:\Develop\Com.Zfrong.Arch\Common\Data\NH\test2.cs:行号 107
  InnerException: System.MissingMethodException
       Message=没有为该对象定义无参数的构造函数。
       Source=mscorlib
       StackTrace:
            在 System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
            在 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
            在 System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
            在 System.Activator.CreateInstance(Type type, Boolean nonPublic)
            在 System.Activator.CreateInstance(Type type)
            在 NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type)
            在 NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary`2 properties)

       InnerException:

Solve
Program
     

#region
            configuration.Cache(c => //(Cache)
            {
                c.UseQueryCache = DefaultUseQueryCache;
                c.UseMinimalPuts = true;
                c.RegionsPrefix = "Cache";
                c.DefaultExpiration = 60;//秒
                if (DefaultUseSecondLevelCache)
                {
                     c.Provider<HashtableCacheProvider>();//
                     // c.QueryCache<StandardQueryCache>();//   is  error 

                    //is OK

                      configuration.SetProperty(Environment.UseSecondLevelCache, "true");
                     configuration.SetProperty(Environment.QueryCacheFactory, typeof(StandardQueryCacheFactory).FullName);

                }

            });
            #endregion


org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of entity.Student.id at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:195) at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:199) at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3605) at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3321) at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:204) at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:241) at org.hibernate.type.ManyToOneType.disassemble(ManyToOneType.java:186) at org.hibernate.cache.StandardQueryCache.put(StandardQueryCache.java:101) at org.hibernate.loader.Loader.putResultInQueryCache(Loader.java:2212) at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2163) at org.hibernate.loader.Loader.list(Loader.java:2121) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1597) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:342) at $Proxy6.list(Unknown Source) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306) at dao.student.StudentDAOImpl.findStudentList(StudentDAOImpl.java:59) at service.student.StudentServiceImpl.findStudentList(StudentServiceImpl.java:14) at servlet.student.findStudentList.doPost(findStudentList.java:53) at servlet.student.findStudentList.doGet(findStudentList.java:61) at javax.servlet.http.HttpServlet.service(HttpServlet.java:624) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at filter.openSessionInView.doFilter(openSessionInView.java:33) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2517) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2506) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:619) Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:169) ... 46 more java.lang.RuntimeException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of entity.Student.id at dao.student.StudentDAOImpl.findStudentList(StudentDAOImpl.java:70) at service.student.StudentServiceImpl.findStudentList(StudentServiceImpl.java:14) at servlet.student.findStudentList.doPost(findStudentList.java:53) at servlet.student.findStudentList.doGet(findStudentList.java:61) at javax.servlet.http.HttpServlet.service(HttpServlet.java:624) at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at filter.openSessionInView.doFilter(openSessionInView.java:33) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2517) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2506) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:619) Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of entity.Student.id at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:195) at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:199) at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3605) at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3321) at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:204) at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:241) at org.hibernate.type.ManyToOneType.disassemble(ManyToOneType.java:186) at org.hibernate.cache.StandardQueryCache.put(StandardQueryCache.java:101) at org.hibernate.loader.Loader.putResultInQueryCache(Loader.java:2212) at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2163) at org.hibernate.loader.Loader.list(Loader.java:2121) at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:118) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1597) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:342) at $Proxy6.list(Unknown Source) at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306) at dao.student.StudentDAOImpl.findStudentList(StudentDAOImpl.java:59) ... 26 more Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:169) ... 46 more
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页