I am not sure if this is the right way to discuss a five year old issue, but I try it .
I detected some strange differences between the String and Long handling in criteria predicates.
Predicate predicateString = b.equal(from.get("name"), "Steve"); Predicate predicateInteger = b.equal(from.get("age"), 42);
This behavior comes from:
public String render(RenderingContext renderingContext) {
if (ValueHandlerFactory.isNumeric(literal)) {
return ValueHandlerFactory.determineAppropriateHandler((Class) literal.getClass()).render(literal);
}
final String parameterName = renderingContext.registerLiteralParameterBinding(getLiteral(), getJavaType());
return ':' + parameterName;
}
The isNumeric() condition was a result of this issue.
I think it is much better for the database to use bind parameters, even for numeric parameters. The database can save compiling very similar statements. Additional, this change bloats the query statistics, because for each query with a different age an additional entry will be stored.
|