Mybatis3:there is no getter for property named ' Code ' in ' Class java.lang.String '

Source: Internet
Author: User
Tags mysql text reflector

Mybatis3:mysql text as follows, the incoming parameter is string type ' Precode ', run Error: There is no getter for the property named ' Precode ' in ' class Java.lang.Str Ing

Execute SQL:

Mapper.xml file:

    <SelectID= "Getmaxcode"ParameterType= "string"Resulttype= "string">select MAX (code) as code from<includerefID= "T_purchase_yearconstact"/>        <where>            <ifTest= "Precode ! = null and Precode! =" ">and code like #{precode}</if>        </where>    </Select>

Found that the parameter cannot be set to the name in the bean, if the input type is a string type , then the parameter needs to be uniformly modified to {_parameter}, the modified SQL statement as follows (regardless of your parameters are what, you have to change to "_ Parameter ")

Corrected mapper file:

<SelectID= "Getmaxcode"ParameterType= "string"Resulttype= "string">select MAX (code) as code from<includerefID= "T_purchase_yearconstact"/>        <where>            <ifTest= "_parameter ! = null and _parameter! =" ">and code like #{_parameter}</if>        </where>    </Select>

This is possible!!!

Error:

Org.mybatis.spring.MyBatisSystemException:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ' Precode ' in ' Class java.lang.String '
At Org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible (Mybatisexceptiontranslator.java : 73)
At Org.mybatis.spring.sqlsessiontemplate$sqlsessioninterceptor.invoke (sqlsessiontemplate.java:365)
At Com.sun.proxy. $Proxy 12.selectOne (Unknown Source)
At Org.mybatis.spring.SqlSessionTemplate.selectOne (sqlsessiontemplate.java:160)
At Com.banksteel.erp.purchase.dao.impl.PurchaseYearconstactDaoImpl.getMaxCode (Purchaseyearconstactdaoimpl.java : 18)
At Com.banksteel.erp.purchase.service.impl.PurchaseYearconstactServiceImpl.getCode ( purchaseyearconstactserviceimpl.java:165)
At Com.banksteel.erp.purchase.service.impl.PurchaseYearconstactServiceImpl.createPurchaseYearconstact ( PURCHASEYEARCONSTACTSERVICEIMPL.JAVA:49)
At Com.banksteel.erp.purchase.PurchaseYearconstactServiceTest.testInsert (Purchaseyearconstactservicetest.java : 58)
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.junit.runners.model.frameworkmethod$1.runreflectivecall (frameworkmethod.java:45)
At Org.junit.internal.runners.model.ReflectiveCallable.run (reflectivecallable.java:15)
At org.junit.runners.model.FrameworkMethod.invokeExplosively (frameworkmethod.java:42)
At Org.junit.internal.runners.statements.InvokeMethod.evaluate (invokemethod.java:20)
At Org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate ( runbeforetestmethodcallbacks.java:74)
At Org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate ( RUNAFTERTESTMETHODCALLBACKS.JAVA:83)
At Org.springframework.test.context.junit4.statements.SpringRepeat.evaluate (springrepeat.java:72)
At Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild (springjunit4classrunner.java:231)
At Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild (springjunit4classrunner.java:88)
At Org.junit.runners.parentrunner$3.run (parentrunner.java:231)
At Org.junit.runners.parentrunner$1.schedule (parentrunner.java:60)
At Org.junit.runners.ParentRunner.runChildren (parentrunner.java:229)
At org.junit.runners.parentrunner.access$000 (parentrunner.java:50)
At Org.junit.runners.parentrunner$2.evaluate (parentrunner.java:222)
At Org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate ( RUNBEFORETESTCLASSCALLBACKS.JAVA:61)
At Org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate ( RUNAFTERTESTCLASSCALLBACKS.JAVA:71)
At Org.junit.runners.ParentRunner.run (parentrunner.java:300)
At Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run (springjunit4classrunner.java:174)
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 ' Precode ' in ' Class JAV A.lang.string '
At Org.apache.ibatis.reflection.Reflector.getGetInvoker (reflector.java:377)
At Org.apache.ibatis.reflection.MetaClass.getGetInvoker (metaclass.java:167)
At Org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty (beanwrapper.java:149)
At Org.apache.ibatis.reflection.wrapper.BeanWrapper.get (beanwrapper.java:45)
At Org.apache.ibatis.reflection.MetaObject.getValue (metaobject.java:113)
At Org.apache.ibatis.scripting.xmltags.dynamiccontext$contextmap.get (dynamiccontext.java:89)
At Org.apache.ibatis.scripting.xmltags.dynamiccontext$contextaccessor.getproperty (DynamicContext.java:107)
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:45)
At Org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean (expressionevaluator.java:29)
At Org.apache.ibatis.scripting.xmltags.IfSqlNode.apply (ifsqlnode.java:30)
At Org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply (mixedsqlnode.java:29)
At Org.apache.ibatis.scripting.xmltags.TrimSqlNode.apply (trimsqlnode.java:47)
At Org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply (mixedsqlnode.java:29)
At ORG.APACHE.IBATIS.SCRIPTING.XMLTAGS.DYNAMICSQLSOURCE.GETBOUNDSQL (dynamicsqlsource.java:37)
At ORG.APACHE.IBATIS.MAPPING.MAPPEDSTATEMENT.GETBOUNDSQL (mappedstatement.java:265)
At Org.apache.ibatis.executor.CachingExecutor.query (cachingexecutor.java:79)
At Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:104)
At Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:98)
At Org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne (defaultsqlsession.java:62)
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:355)
... More

---restore content ends---

Mybatis3:there is no getter-named ' Code ' in ' Class java.lang.String '

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.