MyBatis parameter Issues

Source: Internet
Author: User

Load method, to the SQL statement to pass a parameter of the kind, it seems that parametertype is not so important, do not write actually can, and SQL statements such as Username=#{a} in this can be casually written, as long as the pass is a string type, It is automatically taken out, followed by a single quotation mark, and then put in the SQL statement.

But if there are more than one parameter to set, then one by one corresponds, or with the object's property one by one corresponds to, or with the map of the key and the #{} of the thing one by one corresponding (the value will be put into the SQL statement). Here to pay great attention to the difference between #{} and ${}, the value that #{} takes out, and the double quotation marks are placed in the SQL statement, and ${} is not directly quoted, if the int type, or some type of string that does not need double quotes (for example, as the ID of the keyword, DESC, etc.) can choose this. But if you use #, in a single argument, the curly braces can be written casually, will be added automatically, but with $, the curly braces inside to have this property.

SELECT * from T_user where id=1 (or id= ' 1 ') can be taken out.

MyBatis parameter Issues

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.