我有下一个问题。带“in”运算符和空列表的条件
我有未来的标准:
criteria.add(Restrictions.in("entity.otherEntity", getOtherEntitiesList()));
如果我的otherEntitiesList是空的。休眠生成下一个查询:
select count(*) as y0_
from OTHER_ENTITY this_
where this_.OTHER_ENTITY_ID in ()
和我从甲骨文得到例外。
我发现在Hibernate中下一行代码:
String params = values.length > 0 ? StringHelper.repeat(
singleValueParam + ", ", values.length - 1)
+ singleValueParam : "";
这是不可能使用这种方法生成的标准。 我需要一种方式来生成空列表的Hibernate标准。如果列表为空,我希望得到空的答案。
可能吗?
感谢
如果该列表是空的,不应该有一个结果,所以只需返回一个空列表而不进行查询。 –