|
|
@ -58,19 +58,35 @@ public class LiteralExpression<T> extends ExpressionImpl<T> implements Serializa |
|
|
|
return ':' + parameterName; |
|
|
|
return ':' + parameterName; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 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"}) |
|
|
|
@SuppressWarnings({"unchecked"}) |
|
|
|
public String renderProjection(RenderingContext renderingContext) { |
|
|
|
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
|
|
|
|
// some drivers/servers do not like parameters in the select clause
|
|
|
|
final ValueHandlerFactory.ValueHandler handler = |
|
|
|
final ValueHandlerFactory.ValueHandler handler = |
|
|
|
ValueHandlerFactory.determineAppropriateHandler(literal.getClass()); |
|
|
|
ValueHandlerFactory.determineAppropriateHandler(literal.getClass()); |
|
|
|
if ( ValueHandlerFactory.isCharacter( literal ) ) { |
|
|
|
|
|
|
|
return '\'' + handler.render( literal ) + '\''; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
return handler.render(literal); |
|
|
|
return handler.render(literal); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
@SuppressWarnings({ "unchecked" }) |
|
|
|
@SuppressWarnings({ "unchecked" }) |
|
|
|
protected void resetJavaType(Class targetType) { |
|
|
|
protected void resetJavaType(Class targetType) { |
|
|
|