[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2997?page=c...
]
Albert Fried commented on HHH-2997:
-----------------------------------
The problem is IMHO in the class org.hibernate.criterion.LikeExpression (see the
comments):
public String toSqlString(
Criteria criteria,
CriteriaQuery criteriaQuery) throws HibernateException {
Dialect dialect = criteriaQuery.getFactory().getDialect();
String[] columns = criteriaQuery.getColumnsUsingProjection( criteria, propertyName );
if ( columns.length != 1 ) {
throw new HibernateException( "Like may only be used with single-column
properties" );
}
// THIS IS OK:
String lhs = ignoreCase
? dialect.getLowercaseFunction() + '(' + columns[0] + ')'
: columns[0];
return lhs + " like ?" + ( escapeChar == null ? "" : " escape
\'" + escapeChar + "\'" );
}
public TypedValue[] getTypedValues(
Criteria criteria,
CriteriaQuery criteriaQuery) throws HibernateException {
// THIS IS NOT OK BECAUSE ALWAYS .toLowerCase():
return new TypedValue[] {
criteriaQuery.getTypedValue( criteria, propertyName, value.toString().toLowerCase() )
// THIS COULD BE OK:
// return new TypedValue[] {
// criteriaQuery.getTypedValue( criteria, propertyName,
// ignoreCase ? value.toString().toLowerCase() : value.toString() )
};
}
LikeExpression case sensitive not working properly
--------------------------------------------------
Key: HHH-2997
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2997
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.2.5
Environment: Hibernate 3.2.5
Reporter: Adam Czysciak
Priority: Minor
Attachments: hibernate2997test.zip, LikeExpression.patch, LikeExpression.patch
LikeExpression doesn't handle ignoreCase flag properly when it's set to false.
Uses it to build correct sql "property like ?", but doesn't use the flag
inside getTypedValues - produces always lowercase value to bind.
Attached a patch for 3.2.5
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira