HHH-10412 : case/when in criteria always casts resulting object which fails on mysql with boolean

(cherry picked from commit b1fef6c70b)
This commit is contained in:
Gail Badner 2016-02-09 12:50:56 -08:00
parent 44e4608fd5
commit b540ad43ee
1 changed files with 7 additions and 0 deletions

View File

@ -21,6 +21,13 @@ public class CaseLiteralExpression<T> extends LiteralExpression<T> {
@Override
public String render(RenderingContext renderingContext) {
// There's no need to cast a boolean value and it actually breaks on
// MySQL and MariaDB because they don't support casting to bit.
// Skip the cast for a boolean literal.
if ( getJavaType() == Boolean.class && Boolean.class.isInstance( getLiteral() ) ) {
return super.render( renderingContext );
}
// wrapping the result in a cast to determine the node type during the antlr hql parsing phase
return CastFunction.CAST_NAME + '(' +
super.render( renderingContext ) +