|
|
|
@ -58,17 +58,34 @@ public class LiteralExpression<T> extends ExpressionImpl<T> implements Serializa
|
|
|
|
|
return ':' + parameterName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@SuppressWarnings({ "unchecked" }) |
|
|
|
|
/** |
|
|
|
|
* Inline String literal. |
|
|
|
|
* |
|
|
|
|
* @return escaped String |
|
|
|
|
*/ |
|
|
|
|
private String inlineLiteral(String literal) { |
|
|
|
|
return String.format("\'%s\'", escapeLiteral(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() ); |
|
|
|
|
if ( ValueHandlerFactory.isCharacter( literal ) ) { |
|
|
|
|
return '\'' + handler.render( literal ) + '\''; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
return handler.render( literal ); |
|
|
|
|
} |
|
|
|
|
ValueHandlerFactory.determineAppropriateHandler(literal.getClass()); |
|
|
|
|
return handler.render(literal); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|