We're updating the issue view to help you get more done. 

Case Insensitive Equality Criterion NVARCHAR field yields bad SQL

Description

Example:

1 2 3 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.

Environment

None

Status

Assignee

Unassigned

Reporter

Chris Cranford

Labels

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

4.2.2
5.0.2

Priority

Major