140. Spring Boot MyBatis Upgrade - Annotation - # and $ Symbol Special

 

【Video & Communication Platform】

à SpringBoot Video 

http://study.163.com/course/introduction.htm?courseId=1004329008&utm_campaign=commission&utm_source=400000000155061&utm_medium=share

à  SpringCloud video

http://study.163.com/course/introduction.htm?courseId=1004638001&utm_campaign=commission&utm_source=400000000155061&utm_medium=share

à Spring Boot source code 

https://gitee.com/happyangellxq520/spring-boot

à Spring Boot communication platform 

http://412887952-qq-com.iteye.com/blog/2321532

 

[This blog, there is a supporting video, the video address: " Spring Boot MyBatis Upgrade - Annotation - # and $ Symbol Special ( HD) " , click the following to read the original text in the official account, and the video will explain in more detail]

The # and $ symbols play a very important role in MyBatis 's SQL parameter injection. These two symbols still need to be understood clearly, otherwise the attacked SQL statement may be written . Well, this article is to solve the respective usage scenarios of # and $ .

 

Outline of this section:

(1) #, $ description
(2) Example description
(3) Practice is more proficient
(4) The blogger has something to say

     Next, please move to the WeChat public account SpringBoot to browse:

 

Check the springboot official account article for details (the official account QR code, enter 140 to return to the article):

 

 

-----------------------------------------------------------

Example description:

à Statements using #{} :

@Select("Select * from Demo where name = #{name}")
public List<Demo> selectByName1(@Param("name") String name);

 

Explanation: This example creates a precompiled statement that looks like: select * from Demo where name = ?;

Observe the console's SQL print:

selectByName1    : ==>  Preparing: Select * from Demo where name = ?
DemoMapper.selectByName1    : ==> Parameters: 王五(String)
 
DemoMapper.selectByName1    : <==      Total: 9

 

 

 

 

视频&交流平台

à SpringBoot网易云课堂视频

http://study.163.com/course/introduction.htm?courseId=1004329008

à Spring Boot交流平台

http://412887952-qq-com.iteye.com/blog/2321532

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326989248&siteId=291194637