HHH-4774 - Do not handle literals using parameters in JPA criteria select

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18482 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2010-01-09 16:44:59 +00:00
parent c0636fee4c
commit 5263d4c12a
2 changed files with 22 additions and 1 deletions

View File

@ -54,6 +54,18 @@ public class ValueHandlerFactory {
}
}
public static boolean isCharacter(Class type) {
return String.class.isAssignableFrom( type )
|| Character.class.isAssignableFrom( type )
|| Character.TYPE.equals( type );
}
public static boolean isCharacter(Object value) {
return String.class.isInstance( value )
|| Character.class.isInstance( value )
|| Character.TYPE.isInstance( value );
}
public static boolean isNumeric(Class type) {
return Number.class.isAssignableFrom( type )
|| Byte.TYPE.equals( type )

View File

@ -88,8 +88,17 @@ public class LiteralExpression<T> extends ExpressionImpl<T> implements Serializa
return ':' + parameterName;
}
@SuppressWarnings({ "unchecked" })
public String renderProjection(CriteriaQueryCompiler.RenderingContext renderingContext) {
return render( renderingContext );
// some drivers/servers do not like parameters in the select clause
final ValueHandlerFactory.ValueHandler handler =
ValueHandlerFactory.determineAppropriateHandler( literal.getClass() );
if ( ! ValueHandlerFactory.isCharacter( literal ) ) {
return '\'' + handler.render( literal ) + '\'';
}
else {
return handler.render( literal );
}
}
@Override