Mybaits non-configuration cause sqlsession is not registered for synchronization exception

Source: Internet
Author: User
Tags reflector wrapper

Run the program Times today.

sqlsession [[email protected]] was wasn't registered for synchronization because synchronization are not active

[11:03:17]-closing Non transactional sqlsession [[email protected]]

Because the exception is centralized processing, so reported this error, check for a long time, the online results are said configuration file error, but my project configuration file is certainly correct, because the project has been developed for a long period, but I wrote a method today to report this error, so the exclusion of the configuration file error, But I wrote the method should be no problem, it was written before.

On-line search for half a day did not find the reason, no way, can only look at their own program, the way to write their own unusual direct printing out, the first not concentrated processing, and then abnormal out:

Org.mybatis.spring.MyBatisSystemException:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ' Departid ' in ' Class java.lang.String '

At Org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible (Mybatisexceptiontranslator.java : 75)

At Org.mybatis.spring.sqlsessiontemplate$sqlsessioninterceptor.invoke (sqlsessiontemplate.java:371)

At Com.sun.proxy. $Proxy 15.selectOne (Unknown Source)

At Org.mybatis.spring.SqlSessionTemplate.selectOne (sqlsessiontemplate.java:163)

At Org.apache.ibatis.binding.MapperMethod.execute (mappermethod.java:68)

At Org.apache.ibatis.binding.MapperProxy.invoke (mapperproxy.java:52)

At Com.sun.proxy. $Proxy 125.selectCount (Unknown Source)

At Com.sinog2c.service.impl.yzgl.TbyzScoreServiceImpl.selectCount (tbyzscoreserviceimpl.java:66)

At Com.sinog2c.mvc.controller.yzgl.criminalexam.JifenController.getLastMonthScoreList (jifencontroller.java:76)

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.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod ( handlermethodinvoker.java:175)

At Org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod ( annotationmethodhandleradapter.java:446)

At Org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle ( annotationmethodhandleradapter.java:434)

At Org.springframework.web.servlet.DispatcherServlet.doDispatch (dispatcherservlet.java:938)

At Org.springframework.web.servlet.DispatcherServlet.doService (dispatcherservlet.java:870)

At Org.springframework.web.servlet.FrameworkServlet.processRequest (frameworkservlet.java:961)

At Org.springframework.web.servlet.FrameworkServlet.doGet (frameworkservlet.java:852)

At Javax.servlet.http.HttpServlet.service (httpservlet.java:617)

At Org.springframework.web.servlet.FrameworkServlet.service (frameworkservlet.java:837)

At Javax.servlet.http.HttpServlet.service (httpservlet.java:723)

At Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:290)

At Org.apache.catalina.core.ApplicationFilterChain.doFilter (applicationfilterchain.java:206)

At Com.alibaba.druid.support.http.WebStatFilter.doFilter (webstatfilter.java:124)

At Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:235)

At Org.apache.catalina.core.ApplicationFilterChain.doFilter (applicationfilterchain.java:206)

At Org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal (characterencodingfilter.java:88)

At Org.springframework.web.filter.OncePerRequestFilter.doFilter (onceperrequestfilter.java:107)

At Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:235)

At Org.apache.catalina.core.ApplicationFilterChain.doFilter (applicationfilterchain.java:206)

At Org.apache.catalina.core.StandardWrapperValve.invoke (standardwrappervalve.java:233)

At Org.apache.catalina.core.StandardContextValve.invoke (standardcontextvalve.java:191)

At Org.apache.catalina.core.StandardHostValve.invoke (standardhostvalve.java:127)

At Org.apache.catalina.valves.ErrorReportValve.invoke (errorreportvalve.java:103)

At Org.apache.catalina.core.StandardEngineValve.invoke (standardenginevalve.java:109)

At Org.apache.catalina.connector.CoyoteAdapter.service (coyoteadapter.java:293)

At Org.apache.coyote.http11.Http11Processor.process (http11processor.java:861)

At Org.apache.coyote.http11.http11protocol$http11connectionhandler.process (http11protocol.java:606)

At Org.apache.tomcat.util.net.jioendpoint$worker.run (jioendpoint.java:489)

At Java.lang.Thread.run (thread.java:662)

Caused By:org.apache.ibatis.reflection.ReflectionException:There is no getter for property named ' Departid ' in ' Class Ja Va.lang.String '

At Org.apache.ibatis.reflection.Reflector.getGetInvoker (reflector.java:380)

At Org.apache.ibatis.reflection.MetaClass.getGetInvoker (metaclass.java:170)

At Org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty (beanwrapper.java:152)

At Org.apache.ibatis.reflection.wrapper.BeanWrapper.get (beanwrapper.java:48)

At Org.apache.ibatis.reflection.MetaObject.getValue (metaobject.java:116)

At Org.apache.ibatis.scripting.xmltags.dynamiccontext$contextmap.get (dynamiccontext.java:97)

At Org.apache.ibatis.scripting.xmltags.dynamiccontext$contextaccessor.getproperty (DynamicContext.java:116)

At Org.apache.ibatis.ognl.OgnlRuntime.getProperty (ognlruntime.java:1657)

At Org.apache.ibatis.ognl.ASTProperty.getValueBody (astproperty.java:92)

At Org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody (simplenode.java:170)

At Org.apache.ibatis.ognl.SimpleNode.getValue (simplenode.java:210)

At Org.apache.ibatis.ognl.ASTNotEq.getValueBody (astnoteq.java:49)

At Org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody (simplenode.java:170)

At Org.apache.ibatis.ognl.SimpleNode.getValue (simplenode.java:210)

At Org.apache.ibatis.ognl.ASTAnd.getValueBody (astand.java:56)

At Org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody (simplenode.java:170)

At Org.apache.ibatis.ognl.SimpleNode.getValue (simplenode.java:210)

At Org.apache.ibatis.ognl.Ognl.getValue (ognl.java:333)

At Org.apache.ibatis.ognl.Ognl.getValue (ognl.java:413)

At Org.apache.ibatis.ognl.Ognl.getValue (ognl.java:395)

At Org.apache.ibatis.scripting.xmltags.OgnlCache.getValue (ognlcache.java:48)

At Org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean (expressionevaluator.java:32)

At Org.apache.ibatis.scripting.xmltags.IfSqlNode.apply (ifsqlnode.java:33)

At Org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply (mixedsqlnode.java:32)

At ORG.APACHE.IBATIS.SCRIPTING.XMLTAGS.DYNAMICSQLSOURCE.GETBOUNDSQL (dynamicsqlsource.java:40)

At ORG.APACHE.IBATIS.MAPPING.MAPPEDSTATEMENT.GETBOUNDSQL (mappedstatement.java:278)

At Org.apache.ibatis.executor.CachingExecutor.query (cachingexecutor.java:75)

At Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:108)

At Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:102)

At Org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne (defaultsqlsession.java:66)

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.mybatis.spring.sqlsessiontemplate$sqlsessioninterceptor.invoke (sqlsessiontemplate.java:358)

... More

According to this anomaly re-check the program, found that the problem appears in Departid this parameter, and then check the source program, found that the original I wrote the method of SQL in the Mapper.xml file reference to the parameter departid to determine whether null or empty, so it is reported there is no Getter for property named ' Departid ' in ' Class Java.lang.String ' exception.

Workaround: First, when the method is passed, add Param parameter identification, such as: Countnum (@Param ("Departid") String Departid);

When the method is passed, the parameter is changed to map or object.


Mybaits non-configuration cause sqlsession is not registered for synchronization exception

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.