- private Query setParameter(Query query, Map<String, Object> map) {
- if (map != null) {
- Set<String> keySet = map.keySet();
- for (String string : keySet) {
- Object obj = map.get(string);
- //这里考虑传入的参数是什么类型,不同类型使用的方法不同
- if(obj instanceof Collection<?>){
- query.setParameterList(string, (Collection<?>)obj);
- }else if(obj instanceof Object[]){
- query.setParameterList(string, (Object[])obj);
- }else{
- query.setParameter(string, obj);
- }
- }
- }
- return query;
- }
hql动态绑定参数
最新推荐文章于 2022-01-19 17:20:13 发布