sql語句中#{}


例:Student stu = new Student("田七",27,95);
       Map<String,Object> map=new HashMap<String, Object>();
       map.put("nameCon", "張");
       map.put("ageCon", 23);
       map.put("stu", stu);
select id,name,age,score from student where name like '%' #{nameCon} '%' and age > #{ageCon} and score > #{stu.score}
#{}中可以放什么內容:
1)參數對象的屬性
2)隨意內容,此時的#{}是個占位符
3)參數為map時的key
4)參數為map時,若key對應的value為對象,則可將該對象的屬性放入
5)參數的索引號


免責聲明!

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



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