public BasicValuedExpressableType resolveArithmeticType( BasicValuedExpressableType firstType, BasicValuedExpressableType secondType, SqmBinaryArithmetic.Operation operation) { return resolveArithmeticType( firstType, secondType, operation == SqmBinaryArithmetic.Operation.DIVIDE ); }
@Override public Object visitSubtractionExpression(HqlParser.SubtractionExpressionContext ctx) { if ( ctx.expression().size() != 2 ) { throw new ParsingException( "Expecting 2 operands to the - operator" ); } final SqmExpression firstOperand = (SqmExpression) ctx.expression( 0 ).accept( this ); final SqmExpression secondOperand = (SqmExpression) ctx.expression( 1 ).accept( this ); return new SqmBinaryArithmetic( SqmBinaryArithmetic.Operation.SUBTRACT, firstOperand, secondOperand, getSessionFactory().getTypeConfiguration().resolveArithmeticType( (BasicValuedExpressableType) firstOperand.getExpressableType(), (BasicValuedExpressableType) secondOperand.getExpressableType(), SqmBinaryArithmetic.Operation.SUBTRACT ) ); }
@Override public Object visitAdditionExpression(HqlParser.AdditionExpressionContext ctx) { if ( ctx.expression().size() != 2 ) { throw new ParsingException( "Expecting 2 operands to the + operator" ); } final SqmExpression firstOperand = (SqmExpression) ctx.expression( 0 ).accept( this ); final SqmExpression secondOperand = (SqmExpression) ctx.expression( 1 ).accept( this ); return new SqmBinaryArithmetic( SqmBinaryArithmetic.Operation.ADD, firstOperand, secondOperand, getSessionFactory().getTypeConfiguration().resolveArithmeticType( (BasicValuedExpressableType) firstOperand.getExpressableType(), (BasicValuedExpressableType) secondOperand.getExpressableType(), SqmBinaryArithmetic.Operation.ADD ) ); }
@Override public Object visitMultiplicationExpression(HqlParser.MultiplicationExpressionContext ctx) { if ( ctx.expression().size() != 2 ) { throw new ParsingException( "Expecting 2 operands to the * operator" ); } final SqmExpression firstOperand = (SqmExpression) ctx.expression( 0 ).accept( this ); final SqmExpression secondOperand = (SqmExpression) ctx.expression( 1 ).accept( this ); return new SqmBinaryArithmetic( SqmBinaryArithmetic.Operation.MULTIPLY, firstOperand, secondOperand, getSessionFactory().getTypeConfiguration().resolveArithmeticType( (BasicValuedExpressableType) firstOperand.getExpressableType(), (BasicValuedExpressableType) secondOperand.getExpressableType(), SqmBinaryArithmetic.Operation.MULTIPLY ) ); }
@Override public Object visitDivisionExpression(HqlParser.DivisionExpressionContext ctx) { if ( ctx.expression().size() != 2 ) { throw new ParsingException( "Expecting 2 operands to the / operator" ); } final SqmExpression firstOperand = (SqmExpression) ctx.expression( 0 ).accept( this ); final SqmExpression secondOperand = (SqmExpression) ctx.expression( 1 ).accept( this ); return new SqmBinaryArithmetic( SqmBinaryArithmetic.Operation.DIVIDE, firstOperand, secondOperand, getSessionFactory().getTypeConfiguration().resolveArithmeticType( (BasicValuedExpressableType) firstOperand.getExpressableType(), (BasicValuedExpressableType) secondOperand.getExpressableType(), SqmBinaryArithmetic.Operation.DIVIDE ) ); }
@Override public Object visitModuloExpression(HqlParser.ModuloExpressionContext ctx) { if ( ctx.expression().size() != 2 ) { throw new ParsingException( "Expecting 2 operands to the % operator" ); } final SqmExpression firstOperand = (SqmExpression) ctx.expression( 0 ).accept( this ); final SqmExpression secondOperand = (SqmExpression) ctx.expression( 1 ).accept( this ); return new SqmBinaryArithmetic( SqmBinaryArithmetic.Operation.MODULO, firstOperand, secondOperand, getSessionFactory().getTypeConfiguration().resolveArithmeticType( (BasicValuedExpressableType) firstOperand.getExpressableType(), (BasicValuedExpressableType) secondOperand.getExpressableType(), SqmBinaryArithmetic.Operation.MODULO ) ); }