Fix issue with BinaryArithmeticExpression type resolution

This commit is contained in:
Andrea Boriero 2020-07-20 09:15:29 +01:00
parent 3e3db6d352
commit b6ed4b6629
1 changed files with 13 additions and 6 deletions

View File

@ -1671,14 +1671,11 @@ public abstract class BaseSqmToSqlAstConverter
);
}
else {
return new BinaryArithmeticExpression(
toSqlExpression( leftOperand.accept(this) ),
toSqlExpression( leftOperand.accept( this ) ),
expression.getOperator(),
toSqlExpression( rightOperand.accept(this) ),
expression.getNodeType() instanceof BasicValuedMapping
? (BasicValuedMapping) expression.getNodeType()
: (BasicValuedMapping) expression.getLeftHandOperand().getNodeType()
toSqlExpression( rightOperand.accept( this ) ),
getExpressionType( expression )
);
}
}
@ -1687,6 +1684,16 @@ public abstract class BaseSqmToSqlAstConverter
}
}
private BasicValuedMapping getExpressionType(SqmBinaryArithmetic expression) {
SqmExpressable leftHandOperandType = expression.getLeftHandOperand().getNodeType();
if ( leftHandOperandType instanceof BasicValuedMapping ) {
return (BasicValuedMapping) leftHandOperandType;
}
else {
return (BasicValuedMapping) expression.getRightHandOperand().getNodeType();
}
}
private Expression toSqlExpression(Object value) {
return (Expression) value;
}