|
|
@ -58,19 +58,35 @@ public class LiteralExpression<T> extends ExpressionImpl<T> implements Serializa |
|
|
|
return ':' + parameterName; |
|
|
|
return ':' + parameterName; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings({ "unchecked" }) |
|
|
|
/** |
|
|
|
public String renderProjection(RenderingContext renderingContext) { |
|
|
|
* Inline String literal. |
|
|
|
// some drivers/servers do not like parameters in the select clause
|
|
|
|
* |
|
|
|
final ValueHandlerFactory.ValueHandler handler = |
|
|
|
* @return escaped String |
|
|
|
ValueHandlerFactory.determineAppropriateHandler( literal.getClass() ); |
|
|
|
*/ |
|
|
|
if ( ValueHandlerFactory.isCharacter( literal ) ) { |
|
|
|
private String inlineLiteral(String literal) { |
|
|
|
return '\'' + handler.render( literal ) + '\''; |
|
|
|
return String.format("\'%s\'", escapeLiteral(literal)); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
|
|
|
|
return handler.render( literal ); |
|
|
|
/** |
|
|
|
} |
|
|
|
* Escape String literal. |
|
|
|
} |
|
|
|
* |
|
|
|
|
|
|
|
* @return escaped String |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private String escapeLiteral(String literal) { |
|
|
|
|
|
|
|
return literal.replace("'", "''"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings({"unchecked"}) |
|
|
|
|
|
|
|
public String renderProjection(RenderingContext renderingContext) { |
|
|
|
|
|
|
|
if (ValueHandlerFactory.isCharacter(literal)) { |
|
|
|
|
|
|
|
// In case literal is a Character, pass literal.toString() as the argument.
|
|
|
|
|
|
|
|
return inlineLiteral(literal.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// some drivers/servers do not like parameters in the select clause
|
|
|
|
|
|
|
|
final ValueHandlerFactory.ValueHandler handler = |
|
|
|
|
|
|
|
ValueHandlerFactory.determineAppropriateHandler(literal.getClass()); |
|
|
|
|
|
|
|
return handler.render(literal); |
|
|
|
|
|
|
|
} |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@SuppressWarnings({ "unchecked" }) |
|
|
|
@SuppressWarnings({ "unchecked" }) |
|
|
|
protected void resetJavaType(Class targetType) { |
|
|
|
protected void resetJavaType(Class targetType) { |
|
|
|