码迷,mamicode.com
首页 > 数据库 > 详细

sql语句中#{}

时间:2017-10-17 21:45:29      阅读:429      评论:0      收藏:0      [点我收藏+]

标签:sel   like   student   shm   core   where   string   put   语句   

例: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)参数的索引号

sql语句中#{}

标签:sel   like   student   shm   core   where   string   put   语句   

原文地址:http://www.cnblogs.com/zhengzhen0512/p/7683854.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!