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

Case Insensitive Equality Criterion NVARCHAR field yields bad SQL

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      Example:

      Criteria criteria = session.createCriteria(Entity.class);
      criteria.add(Restrictions.eq("someField", someValue).ignoreCase());
      return criteria.list();
      

      The above code does not work on Nationalized (NVARCHAR/NCHAR) fields.

      After investigating, it appears SimpleExpression checks the column data type during an ignoreCase=true scenario and will only apply the SQL dialect specific lower function to the left-hand side of the equation when the column data type is either VARCHAR or CHAR.

      In the case of NVARCHAR and NCHAR fields, the left-hand side of the equality SQL fragment is not wrapped by the SQL dialect lower function, but because the right-hand side value is lowered, the database comparisons fail and yield no results when using NVARCHAR/NCHAR types.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: