Caused By:org.apache.ibatis.reflection.ReflectionException:There is no getter forProperty named'ParentID' inch 'class Java.lang.String'At Org.apache.ibatis.reflection.Reflector.getGetInvoker (Reflector.java:333) at Org.apache.ibatis.reflection.MetaClass.getGetInvoker (Metaclass.java: the) at Org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty (Beanwrapper.java:151) at Org.apache.ibatis.reflection.wrapper.BeanWrapper.get (Beanwrapper.java: -) at Org.apache.ibatis.reflection.MetaObject.getValue (Metaobject.java:123) at Org.apache.ibatis.builder.xml.dynamic.dynamiccontext$contextmap.get (Dynamiccontext.java: the) at Org.apache.ibatis.builder.xml.dynamic.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: the) at Org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody (Simplenode.java: the) at Org.apache.ibatis.ognl.SimpleNode.getValue (Simplenode.java: About) at Org.apache.ibatis.ognl.ASTNotEq.getValueBody (Astnoteq.java: the) at Org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody (Simplenode.java: the) at Org.apache.ibatis.ognl.SimpleNode.getValue (Simplenode.java: About) 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.builder.xml.dynamic.OgnlCache.getValue (Ognlcache.java: the) at Org.apache.ibatis.builder.xml.dynamic.ExpressionEvaluator.evaluateBoolean (Expressionevaluator.java: +) at org.apache.ibatis.builder.xml.dynamic.IfSqlNode.apply (Ifsqlnode.java: -) at org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply (Mixedsqlnode.java: in) at org.apache.ibatis.builder.xml.dynamic.TrimSqlNode.apply (Trimsqlnode.java: the) at org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply (Mixedsqlnode.java: in) at org.apache.ibatis.builder.xml.dynamic.TrimSqlNode.apply (Trimsqlnode.java: the) at org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply (Mixedsqlnode.java: in) at org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply (Mixedsqlnode.java: in) at ORG.APACHE.IBATIS.BUILDER.XML.DYNAMIC.DYNAMICSQLSOURCE.GETBOUNDSQL (Dynamicsqlsource.java:Panax Notoginseng) at ORG.APACHE.IBATIS.MAPPING.MAPPEDSTATEMENT.GETBOUNDSQL (Mappedstatement.java:241) at Org.apache.ibatis.executor.CachingExecutor.query (Cachingexecutor.java: -) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (Defaultsqlsession.java:101) at Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (Defaultsqlsession.java: the) at Sun.reflect.GeneratedMethodAccessor143.invoke (Unknown Source) at Sun.reflect.DelegatingMethodAccessorImpl. Invoke (Delegatingmethodaccessorimpl.java: +) at Java.lang.reflect.Method.invoke (Method.java:606) at Org.mybatis.spring.sqlsessiontemplate$sqlsessioninterceptor.invoke (Sqlsessiontemplate.java:355) ... theMore
Sql:
<! [cdata[ SELECT inn.inner_org_id, inn.org_code from Inner_org Inn, org_relation rel WHERE inn.inner_org_id= rel.relation_id and rel.parent_id = #{parentid} ]]>
Workaround:
Replace the parameter name (' ParentID ') with "_parameter"
Answers to questions about the great God of GitHub:
- As documented, is
parameterType optional and it's usually better to let MyBatis detect it.
- As your statement have one simple type parameter without
@Param annotation, you need to use the implicit name to _parameter refer ence it in the OGNL expression or ${}.
- Java does not allow us to obtain the parameter name at runtime, unfortunately. Please search ' java parameter name ' for more detailed explanation.
So, as I explained.
1) Modify the XML mapper as follows:
1 2 3
|
<test="_parameter < 0 "> id = 0-#{id} </when>
|
Or 2) Add @Param ("id") to the method parameter.
1
|
FindByID(@Param ("id")int id);
|
Org.apache.ibatis.reflection.ReflectionException:There is no getter for property named ' ParentID ' in ' class java.lang.St Ring