MyBatis Package There is no getter for property named ' XXX ' in ' Class java.lang.String '

Source: Internet
Author: User

First, the problem found

<select id= "Querystudentbynum" resulttype= "Student" parametertype= "string" >

Select Num,name,phone from Student
<where>
<if test = "Num!=null and num!=" >
and num = #{num}
</if>
</where>
</select>
The MyBatis query passes in a string-pass parameter, and is reported to there is no getters for the property named ' Num ' in ' Class java.lang.String '.


Second, solve the problem

<select id= "Querystudentbynum" resulttype= "Student" parametertype= "string" >

Select Num,name,phone from student
<where>
<if test = " _parameter!=null and _parameter! =" >
and num = #{ _parameter}
</if>
</where>
</select>
Regardless of the parameter name, change to "_parameter".


Third, the reason analysis

MyBatis by default with ONGL parsing parameters, so the object tree will automatically take the form of string.num values, causing error. The public List methodName (@Param (value= "num") String num can also be used to describe the parameter values

MyBatis Package There is no getter for property named ' XXX ' 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.