Search code examples
hibernateequalsisnullrestrictions

How does Hibernate function Restrictions.allEq(Map<String, Object>) treat null values?


I'm wondering how the Hibernate function Restrictions.allEq(Map<String, Object> ...) treats null values inside input Map (if as multiple Restrictions.eq(String, Object) or Restrictions.eqOrIsNull(String, Object)) or whatelse).
After a quick search from Google, I couldn't find anything specific from Hibernate documentation, and only a source says that Restrictions.allEq(...) is equivalent to multiple Restrictions.eq(String, Object) (see here).
I'm not sure that is the correct answer, so I'm asking here. Thank you all in advance


Solution

  • After downloading sources of Hibernate (4.3.6.Final), and a little inspection, I've finally found the answer: Restrictions.allEq(Map<String, Object>) is translated as a bunch of Restrictions.eq(String, Object) and consequently a null value is remapped as the String "null" (which may be or may be not the correct translation, based on the specific application).
    In my case, I needed to use multiple Restrictions.eqOrIsNull(String, Object) to correctly manage my input Map<String, Object>.
    I hope this question will be useful to someone else.