spring的hibernateTemplate中hql如何使用in??
Object[] piid = processInstanceIds.toArray();
return hibernateTemplate.find("select d from Document d where d.processInstanceId in (?)",piid)我这样用报错提示:Remember that ordinal parameters are 1-based!查了下说明是:hql语句里不需要参数,应该是把 in(?) 中的?当字符串解释了.
Object[] piid = processInstanceIds.toArray();
return hibernateTemplate.find("select d from Document d where d.processInstanceId in (?)",piid)我这样用报错提示:Remember that ordinal parameters are 1-based!查了下说明是:hql语句里不需要参数,应该是把 in(?) 中的?当字符串解释了.
(?)是什么数据?
String ids = "1,2,3";
String hql = "select d from Document d where d.processInstanceId in (" + ids + ")";
public BigDecimal getConstFeeAll(Integer year, Integer month, String deptId) {
String hql = "select sum(finalMoney) from DecoConstruction where year(createDate)=? and month(createDate)=? and decoDecoration.id in (select decoDecoration.id from DecoDistribute where coreEmployee.department.id in (" + deptId + ") and type=? and isAvalibled=?)";
Object object = getObject(hql, new Object[]{ year, month, DecoDistribute.TYPE_SALESMAN, true });
return (null != object ? (BigDecimal) object : new BigDecimal(0d));
}
@SuppressWarnings("unchecked")
@Override
public List<Brand> doInHibernate(Session session)
throws HibernateException, SQLException {
return session.createQuery("select distinct o.brand from ProductInfo o where o.productType.id in(:typeids)")
.setParameterList("typeids", typeids)//typeids为集合对象,如果是数组可以自己转下Arrays.asList();
.list();
}
});