I am querying MS SQL Server using Hibernate Criteria, but I have found that queries on varchar columns with Restrictions.eq() do not consider trailing white space.
For example, if my DB has the value "ABC " (5 trailing white space), and I pass the value "ABC" (no white space) to Restrictions.eq(), it finds a match. (The reverse is also true. If my DB has "ABC", and I pass "ABC " to Restrictions.eq(), it finds a match.)
This is not my desired behavior, as the strings are not actually equal.
Oddly, Restrictions.like() does respect Strings' trailing white space... but I don't actually want regex pattern matching.
My ugly hack for now is to add the Restrictions.eq() Criterion, and if the input value is a String also add the Restrictions.like() Criterion. Can anybody think of a better workaround? I'd rather not switch everything from Criteria to HQL.