This article for Bo Master original, without permission may not be reproduced:
Exception display:
The DAO layer defines the interface as:
Public int getclienttotal ();
The SQL in MyBatis is:
<select id= "Getclienttotal" parametertype= "String" resulttype= "Integer" > Select COUNT (*) as Oldnum from Tbl__client_info <where> <if test= "Zoneid!=null and!"" ;. Equals (Zoneid.trim ()) "> = #{zoneid} </if> </where> </select>
At run time, the console reports an exception:
Caused By:org.apache.ibatis.reflection.ReflectionException:There is no getter forProperty named ' ZoneID ' in ' Class java.lang.String 'At Org.apache.ibatis.reflection.Reflector.getGetInvoker (Reflector.java:422) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.reflection.MetaClass.getGetInvoker (Metaclass.java:164) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty (Beanwrapper.java:162) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.reflection.wrapper.BeanWrapper.get (Beanwrapper.java:) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.reflection.MetaObject.getValue (Metaobject.java:122) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.scripting.xmltags.dynamiccontext$contextmap.get (Dynamiccontext.java:94) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.scripting.xmltags.dynamiccontext$contextaccessor.getproperty (DynamicContext.java: 108) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.ognl.OgnlRuntime.getProperty (Ognlruntime.java:2666) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.ognl.ASTProperty.getValueBody (Astproperty.java:) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody (Simplenode.java:212) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.ognl.SimpleNode.getValue (Simplenode.java:258) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.ognl.ASTNotEq.getValueBody (Astnoteq.java:~[mybatis-3.4.2.jar:3.4.2)] at Org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody (Simplenode.java:212) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.ognl.SimpleNode.getValue (Simplenode.java:258) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.ognl.ASTAnd.getValueBody (Astand.java:) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody (Simplenode.java:212) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.ognl.SimpleNode.getValue (Simplenode.java:258) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.ognl.Ognl.getValue (Ognl.java:467) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.ognl.Ognl.getValue (Ognl.java:431) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.scripting.xmltags.OgnlCache.getValue (Ognlcache.java:~[mybatis-3.4.2.jar:3.4.2)] at Org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean (Expressionevaluator.java:~[mybatis-3.4.2.jar:3.4.2)] at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply (Ifsqlnode.java:~[mybatis-3.4.2.jar:3.4.2)] at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply (Mixedsqlnode.java:) ~[mybatis-3.4.2.jar:3.4.2] at org.apache.ibatis.scripting.xmltags.TrimSqlNode.apply (Trimsqlnode.java:~[mybatis-3.4.2.jar:3.4.2)] at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply (Mixedsqlnode.java:) ~[mybatis-3.4.2.jar:3.4.2] at ORG.APACHE.IBATIS.SCRIPTING.XMLTAGS.DYNAMICSQLSOURCE.GETBOUNDSQL (Dynamicsqlsource.java:~[mybatis-3.4.2.jar:3.4.2)] at ORG.APACHE.IBATIS.MAPPING.MAPPEDSTATEMENT.GETBOUNDSQL (Mappedstatement.java:292) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.executor.CachingExecutor.query (Cachingexecutor.java:Bayi) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (Defaultsqlsession.java:148) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (Defaultsqlsession.java:141) ~[mybatis-3.4.2.jar:3.4.2] at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne (Defaultsqlsession.java:) ~[mybatis-3.4.2.jar:3.4.2] at Sun.reflect.GeneratedMethodAccessor90.invoke (Unknown Source)~[Na:na] at Sun.reflect.DelegatingMethodAccessorImpl.invoke (Delegatingmethodaccessorimpl.java:~[na:1.8). 0_121] at Java.lang.reflect.Method.invoke (Method.java:498) ~[na:1.8. 0_121] at Org.mybatis.spring.sqlsessiontemplate$sqlsessioninterceptor.invoke (Sqlsessiontemplate.java:433) ~[mybatis-spring-1.3.1.jar:1.3.1] ... Common frames omitted
Error analysis and resolution methods:
Error reason: In SQL test= "Zoneid!=null and!"". The Equals (Zoneid.trim ()) "condition determines that when MyBatis parses SQL, the attributes in test are parsed into the bean's
The MyBatis property, which is obtained by the GetProperty method when parsing a value, is the same as when SQL retrieves a value from the database and assigns the attribute value to the attribute by SetProperty method. Because
MyBatis the string argument in the interface to the Bean attribute requires a Set,get method, the Set,get method is generally written in the entity class, and the attributes in the interface can be implemented by @param () annotations.
Set,get method.
Modification Method:
Public int getclienttotal (@Param ("ZoneID") String ZoneID);
Then reboot is OK.
Caused By:org.apache.ibatis.reflection.ReflectionException:There is no getter for property named ' ZoneID ' in ' class J Ava.lang.String '