mybatis配置文件中我的sql查询语句有我自己定义的常量 比如 select 1 as day

2024-11-18 19:26:39
推荐回答(1个)
回答(1):

在service中把参数放到HashMap中
List list = new ArrayList();
list.add("x");
list.add("y");
list.add("z");

String s = "A"

Date d = new Date();

HashMap param = new HashMap();

param.put("list",list);
param.put("s",s);
param.put("d",d);

XXXDao.queryXXX(param);

在Mybatis的Mapper中是这么写:

select * from tab where zi_duan1 = #{s} and zi_duan2 = #{d}
and zi_duan3 in
separator="," close=")">
#{item}