Multiple types of parameters in the Java MyBatis Framework are passed into the XML problem

Source: Internet
Author: User

Because of the company's requirements, recently from. NET to Java, and then encountered a variety of wonderful problems in the process, special here with a note.

Scene: A method has two parameters, a list of the collection, an int type of parameters, initially I in the XML SQL parameters, whether defined as a list or int are error, in fact, I can understand carefully, the interface method defines two types of parameters, So the type of argument in your XML is wrong, whatever it is defined as.

Original wording:

======================== This example is an example of the original error notation ===========start

void Batchupdateurgetntstatusnew (list<string> li,int priority);

In XML:

<!--Modify the debit ticket priority--
<update id= "batchupdateurgetntstatusnew" parametertype= "Java.util.List" >

Update table name
<set>
Priority=#{priority,jdbctype=integer},
Modifiedon=now ()
</set>

where Delete_status=0 and loanee_type=0
and loanee_apply_id in
<foreach collection= "li" item= "item" index= "index" separator= ","
Open= "(" close= ")" >
#{item}

</foreach>
</update>

======================== This example is an example of the original error notation ===========end

Later asked the company's colleagues, colleagues told me that the situation in the XML does not define the parameter type, and then changed, run Debug OK.

Here's an example of the change.

Example: @Param ("Li") aliases a parameter, XML can use aliases directly

void Batchupdateurgetntstatusnew (@Param ("Li") list<string> Li, @Param ("priority") int priority);

XML: Medium Without declaring parameter type, parametertype= "Java.util.List"

<!--Modify the debit ticket priority--
<update id= "Batchupdateurgetntstatusnew" >

Update table name
<set>
Priority=#{priority,jdbctype=integer},
Modifiedon=now ()
</set>

where Delete_status=0 and loanee_type=0
and loanee_apply_id in
<foreach collection= "li" item= "item" index= "index" separator= ","
Open= "(" close= ")" >
#{item}

</foreach>
</update>

Multiple types of parameters in the Java MyBatis Framework are passed into the XML problem

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.