【问题标题】:How does Hibernate function Restrictions.allEq(Map<String, Object>) treat null values?Hibernate 函数 Restrictions.allEq(Map<String, Object>) 如何处理空值?
【发布时间】:2014-11-26 09:42:07
【问题描述】:
我想知道 Hibernate 函数 Restrictions.allEq(Map<String, Object> ...) 如何处理输入 Map 中的空值(如果是多个 Restrictions.eq(String, Object) 或 Restrictions.eqOrIsNull(String, Object))或其他)。
从 Google 快速搜索后,我在 Hibernate 文档中找不到任何具体内容,只有消息来源说 Restrictions.allEq(...) 等同于 multiple Restrictions.eq(String, Object)(请参阅 here)。
我不确定这是正确的答案,所以我在这里问。
先谢谢大家了
【问题讨论】:
标签:
hibernate
equals
isnull
restrictions
【解决方案1】:
在下载了Hibernate(4.3.6.Final)的源代码后,稍作检查,我终于找到了答案:Restrictions.allEq(Map<String, Object>)被翻译成一堆Restrictions.eq(String, Object),因此null值被重新映射作为字符串"null"(根据具体应用,可能是也可能不是正确的翻译)。
就我而言,我需要使用多个 Restrictions.eqOrIsNull(String, Object) 来正确管理我的输入 Map<String, Object>。
我希望这个问题对其他人有用。