PHaroZ edited a comment on Bug HHH-3464

agree with this issue.

In my case, with postgresql, i've overriden the PostgreSQL82Dialect#getLowercaseFunction with the following code :

@Override
public String getLowercaseFunction() { return "lower_unaccent"; }

"lower_unaccent" function is defined in my DB to do lowercase(unaccent(string)), so I realy need that both side of conditions use "dialect.getLowercaseFunction()"

To do so, we must modify 2 classes :

org.hibernate.criterion.LikeExpression :
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
...
if (this.ignoreCase) {
if (dialect.supportsCaseInsensitiveLike()) { return column + " " + dialect.getCaseInsensitiveLike() + " ?" + escape; } else {
// EDITED BY ME { return dialect.getLowercaseFunction() + '(' + column + ')' + " like " + dialect.getLowercaseFunction() + '(' + "?" + ')' + escape; // }
}
} else { return column + " like ?" + escape; }
}

org.hibernate.criterion.SimpleExpression :
public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)
throws HibernateException {
// EDITED BY ME { Object icvalue = this.value; // }
return new TypedValue[] { criteriaQuery.getTypedValue(criteria, this.propertyName, icvalue) };
}
public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) throws HibernateException {
...
for (int i = 0; i < columns.length; i++) {
boolean lower = this.ignoreCase && (sqlTypes[i] == Types.VARCHAR || sqlTypes[i] == Types.CHAR);
if (lower) { fragment.append(factory.getDialect().getLowercaseFunction()).append('('); }
fragment.append(columns[i]);
if (lower) { fragment.append(')'); }
// EDITED BY ME {
fragment.append(this.getOp());
if (lower) { fragment.append(factory.getDialect().getLowercaseFunction()).append('('); } }
fragment.append("?");
if (lower) { fragment.append(')'); }
// }
if (i < columns.length - 1) { fragment.append(" and "); }
}
if (columns.length > 1) { fragment.append(')'); }
return fragment.toString();

}

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira