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

Source: Internet
Author: User

MyBatis Version: Mybatis-3.0.6.jar

1. When the entry parameter is of type string (including java.lang.String.)

We use #{xxx} to introduce parameters. Throws an exception there is no getter for property named ' xxx ' in ' Class java.lang.String '

<select id= "Getbookingcount" resulttype= "int" parametertype= "string" >select count (*) from Tb_empc_booking_ ORDER twhere (t.state = ' 1 ' or t.state = ' 2 ') and t.appointmenttime = #{state}</select>

2. Workaround one: Modify #{xxx} to #{_parameter}

<select id= "Getbookingcount" resulttype= "int" parametertype= "string" >select count (*) from Tb_empc_booking_ ORDER twhere (t.state = ' 1 ' or t.state = ' 2 ') and T.appointmenttime = #{_parameter}</select>

3. Workaround two: You can define it in advance in the method:

public int  MethodName (@Param (value= ' state ') String state) {...}

4. Reason: MyBatis by default with ONGL parsing parameters, so will automatically take the form of the object tree string.xxx value, if not defined in the method, will throw an exception error.

5. Other MyBatis version do not know whether there is this problem, not yet tried.

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