<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial><FONT size=2>I ran across a minor code smell in Hibernate
when dealing with case-insensitive like. The offending class
is ILikeExpression<SPAN
class=745462720-02052007>:</SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN
class=745462720-02052007></SPAN></FONT></FONT> </DIV>
<DIV><FONT face=Arial size=2> if ( dialect instanceof
PostgreSQLDialect ) {<BR> return columns[0] + " ilike
?";<BR> }<BR> else {<BR> return
dialect.getLowercaseFunction() + '(' + columns[0] + ") like
?";<BR> }<BR></FONT></DIV>
<DIV><SPAN class=745462720-02052007><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=745462720-02052007>This might be better
and more OO:</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2> </DIV></FONT>
<DIV><FONT face=Arial size=2> String ilikeOperator =
dialect.getILikeOperator();<BR> if ( ilikeOperator != null )
{<BR> return columns[0] + " " + ilikeOperator + "
?";<BR> }<BR> else if (
dialect.areStringComparisonsCaseInsensitive() ) {<BR> return
columns[0] + " like
?";<BR> }<BR> else {<BR> return
dialect.getLowercaseFunction() + '(' + columns[0] + ") like
?";<BR> }<BR></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>PostgresSQLDialect.getILikeOperator() would return
"ilike". All other dialects would return null.<BR></DIV></FONT>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>