Mybatis querying a SQL spelling instance of a parameter

Source: Internet
Author: User

1, in the corresponding ***mapper.java write the corresponding method (focus on the parameters)

Java.util.list<com.thunisoft.sjzljc.pojo.ttjfxwsgz> selectzjxqlist (@Param ("Cbhgzdy") String Cbhgzdy , @Param ("Cropid") String cropid);

2, the corresponding ***mapper.xml in the spelling of SQL

<select id= "selectzjxqlist" resultmap= "Baseresultmap" >
Select C_ah,c_wsmc,c_bh_ws
from {Db.t_tjfx_wsgz}
where c_bh_gzdy = #{cbhgzdy}
<if test= "Cropid!=null" >
and C_BH_DW3 in (${cropid})
</if>
ORDER BY C_ah
</select>

Note: The parameter is preceded by the # sign and the $ symbol, the difference is that, #号有防止SQL注入的功能, the parameters will be processed, but the $ symbol is to get the value of your original pass.

Mybatis querying a SQL spelling instance of a parameter

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.