Uploaded image for project: 'Hibernate ORM'
  1. HHH-7705

Query.setProperties(Map) silently ignores null values provided in the Map

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.1.5.SP1, 5.0.6
    • Fix Version/s: 5.1.0, 5.0.8
    • Component/s: query-hql
    • Environment:
      4.1.5.SP1
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Suitable for new contributors:
      Yes, likely
    • Last commented by a user?:
      true
    • Sprint:

      Description

      In HHH-2037 Closed a Query.setProperties(Map) method was introduced to set query named parameters using a Map. Unfortunately this method silently ignores null values contained in the Map.

      See org.hibernate.internal.AbstractQueryImpl.setProperties(Map), here it is checked whether the value is not null. Only if it is not null it is added as parameter.

      However the Javadoc clearly states that there are Map implementations which contain null values, a return value of null for the java.util.Map.get(Object) method does not necessarily indicate that the key is not contained in the Map. To check whether a key is contained in the Map, the containsKey(Object) method should be used.

      If it is not possible to fix the Query.setProperties(Map) method, the Javadoc regarding this method should at least include a hint that null values are never bound to the named parameters using this method. It might be difficult to bind the null values, because the original type of these values is not known anymore in this method.

        Attachments

          Issue links

            Activity

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: