MyBatis problem: There is no getter for property named ' Unitid ' in ' Class java.lang.String '

Source: Internet
Author: User
Tags reflector

MyBatis problems encountered:
Org.mybatis.spring.MyBatisSystemException:nested exception is org.apache.ibatis.reflection.ReflectionException:there is no getter for property named ' Unitid ' 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 6.selectList (Unknown Source) at Org.mybatis.spring.SqlSessionTemplate.selectList (sqlse Ssiontemplate.java:198) at Org.apache.ibatis.binding.MapperMethod.executeForMany (Mappermethod.java:119) at Org.apache.ibatis.binding.MapperMethod.execute (Mappermethod.java:63) at Org.apache.ibatis.binding.MapperProxy.invoke (Mapperproxy.java:52) at Com.sun.proxy. $Proxy 11.getUsersByUnitId (Unknown Source) at com.thinkPro.steap.db.base.sys.user.UserBase.ge Tusersbyunitid (Userbase.java:125) at Com.thinkPro.steap.db.service.sys.user.UserService.getUsersByUnitId (Userservice.java:188) at Com.thinkPro.steap.test.TestUser.testGetUsersByUnitId (Testuser.java:184) at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at Sun.reflect.NativeMethodAccessorImpl.invoke (Nativemethodaccessorimpl.java:57) at Sun.reflect.DelegatingMethodAccessorImpl.invoke (Delegatingmethodaccessorimpl.java:43) at Java.lang.reflect.Method.invoke (Method.java:30S) at org.junit.runners.model.frameworkmethod$1.runReflectiveCall (frameworkmethod.java:50) at Org.junit.internal.runners.model.ReflectiveCallable.run (Reflectivecallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively (Frameworkmethod.java:47) at Org.junit.internal.runners.statements.InvokeMethod.evaluate (Invokemethod.java:17) at Org.junit.runners.ParentRunner.runLeaf (Parentrunner.java:325) at Org.junit.runners.BlockJUnit4ClassRunner.runChild (Blockjunit4classrunner.java:78) at Org.junit.runners.BlockJUnit4ClassRunner.runChild (Blockjunit4classrunner.java:57) at org.junit.runners.parentrunner$3.run (parentrunner.java:290) at org.junit.runners.parentrunner$1.schedule (parentrunner.java:71) at Org.junit.runners.ParentRunner.runChildren (Parentrunner.java:288) at org.junit.runners.parentrunner.access$(parentrunner.java:58) at org.junit.runners.parentrunner$2.evaluate (parentrunner.java:268) at Org.junit.runners.ParentRunner.run (Parentrunner.java:363) at Org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (Junit4testreference.java:50) at Org.eclipse.jdt.internal.junit.runner.TestExecution.run (Testexecution.java:38) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (Remotetestrunner.java:467) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (Remotetestrunner.java:683) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (Remotetestrunner.java:390) at Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (Remotetestrunner.java:197)caused By:org.apache.ibatis.reflection.ReflectionException:There is no getter For property named ' Unitid ' in ' Class Java.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:310) at Org.apache.ibatis.scripting.xmltags.OgnlCache.getValue (Ognlcache.java:45) 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.TrimSqlNode.apply (Trimsqlnode.java:54) 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 Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at Sun.reflect.NativeMethodAccessorImpl.invoke (Nativemethodaccessorimpl.java:57) at Sun.reflect.DelegatingMethodAccessorImpl.invoke (Delegatingmethodaccessorimpl.java:43) at Java.lang.reflect.Method.invoke (Method.java:606) at Org.mybatis.spring.sqlsessiontemplate$sqlsessioninterceptor.invoke (Sqlsessiontemplate.java:358)    ... More
Analysis:

So what happens when "there is no getter for property named in ' Class Java.lang.String '" error?

In fact, in this case:

    <SelectID= "Getriskmember"Resultmap= "Baseresultmap" parametertype= "String">         <includerefID= "Selectmember"/>and safetylevel > 1 and stauts = 1 <if  test= "Username! = null"> and username = #{username}</if>    </Select>

Note that it is the "there is no getter-named in ' Class Java.lang.String '" that occurs when the if test= is verified,

Instead of an error that occurs when and username = #{username}.

Workaround:
  <SelectID= "Getriskmember"Resultmap= "Baseresultmap"ParameterType= "String">        <includerefID= "Selectmember"/>and safetylevel > 1 and stauts = 1<ifTest="_parameter! = null" >and username = #{username}</if>    </Select>

MyBatis problem: There is no getter-named ' Unitid ' in ' Class java.lang.String '

Related Article

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.