我有这些测试查询:
String query = "";
Query criteria;
query =
"from Test t " +
"where (:value is null OR t.id = :value)"; // update: (t.id = (:value))
criteria = session.createQuery(query);
if (.. some condition ..) {
criteria.setParameter("value", 0);
}
else {
criteria.setParameter("value", null);
}
如何仅使用参数将 where 条件从更改id = 0
为(id = 0 or id = 1)
(resp。 )?id < 2
value