Mybaits Error Resolution: There is no getter-named ' ID ' in class ' java.lang.String '

Source: Internet
Author: User

When using Mybaitis to pass parameters, if only one parameter of type string is passed in, the XML file should use _parameter instead of the parameter name.


The correct wording:

[HTML]View Plaincopyprint?
  1. <span style="FONT-SIZE:18PX;" > <!--used to inquire if the waybill number is present -
  2. <Select id= "iscargobillnoexist" resulttype="Java.lang.Integer">
  3. Select COUNT (1)
  4. From T_entry_cargo_receiver_info
  5. where 1=1
  6. <if test="_parameter! = null" >
  7. and cargo_bill_no = #{<span style="color: #ff0000;" >_parameter</span;,jdbctype=VARCHAR}
  8. </If>
  9. </Select></span>


The wrong wording:

[HTML]View Plaincopyprint?
  1. <span style="FONT-SIZE:18PX;" > <!--used to inquire if the waybill number is present -
  2. <Select id= "iscargobillnoexist" resulttype="Java.lang.Integer">
  3. Select COUNT (1)
  4. From T_entry_cargo_receiver_info
  5. where 1=1
  6. <if test="id! = NULL" >
  7. and cargo_bill_no = #{<span style="color: #ff0000;" >id</span;,jdbctype=VARCHAR}
  8. </If>
  9. </Select></span>



The comment area was mentioned:

You can also add @param (value= "id") to the parameters of this method in the Mapper interface, so that you can use #{id,jdbctype=varchar} in. Xml.

It's also possible.

=============== Split Line ===============

However, the errors mentioned in this article are found in practice and are not always present. may be related to the version of MyBatis, that is, according to the "error" above the writing, in some versions is not a problem, do not have to tangle.

If there is a header error, you can resolve it as described in the article.

Mybaits Error Resolution: There is no getter-named ' ID ' 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.