使用Cnd.where("id", "in", ids);查询,ids为空时,理应查询结果为空,但是却返回了全部结果。
错误示例:
public List<Object> getObjects(List<Long> ids){
Condition cnd = Cnd.where("id", "in", ids);
return query(Object.class, cnd);
}
目前正确结果的写法:
public List<Object> getObjects(List<Long> ids){
Condition cnd = Cnd.where("1", "=", 1);
if(ids.isEmpty()){
((Cnd)cnd).and("id", "=", 0);
}else{
((Cnd)cnd).and("id", "in", ids);
}
return query(Object.class, cnd);
}