[hibernate-dev] Smell in ILikeExpression
Mike Slattery
mslattery at searchsoft.net
Wed May 2 17:05:45 EDT 2007
I ran across a minor code smell in Hibernate when dealing with
case-insensitive like. The offending class is ILikeExpression:
if ( dialect instanceof PostgreSQLDialect ) {
return columns[0] + " ilike ?";
}
else {
return dialect.getLowercaseFunction() + '(' + columns[0] + ") like
?";
}
This might be better and more OO:
String ilikeOperator = dialect.getILikeOperator();
if ( ilikeOperator != null ) {
return columns[0] + " " + ilikeOperator + " ?";
}
else if ( dialect.areStringComparisonsCaseInsensitive() ) {
return columns[0] + " like ?";
}
else {
return dialect.getLowercaseFunction() + '(' + columns[0] + ") like
?";
}
PostgresSQLDialect.getILikeOperator() would return "ilike". All other
dialects would return null.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-dev/attachments/20070502/99c57e00/attachment.html
More information about the hibernate-dev
mailing list