Org.apache.ibatis.reflection.ReflectionException:There is no getter for property named ' ParentID ' in ' class java.lang.St Ring

Source: Internet
Author: User

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 &lt; 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

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.