Java 在使用@Select遇到的問題:拼接字符串將數組拼為了字符串


Java再用@Select拼接sql語句時候,

#{參數名}:是加引號的

${參數名}:是不加引號的

 

例如:

userIds為List或者數組,值為1,2,3,4,5

1.@Select("select * from users where userId in  (#{userIds})")

翻譯為sql語句之后為:select * from users where userId in ('1,2,3,4,5')

2.@Select("select * from users where userId in  (${userIds})")

翻譯為sql語句之后為:select * from users where userId in (1,2,3,4,5)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM