From aeb7601ac9fe0367b230c505062fcc5f3fdbc076 Mon Sep 17 00:00:00 2001 From: Cedomir Igaly Date: Fri, 14 Jun 2024 12:46:42 +0200 Subject: [PATCH] HHH-18274 Properly resolving Java type in binary and unary expressions --- .../org/hibernate/query/sqm/internal/TypecheckUtil.java | 6 +++--- .../query/sqm/tree/expression/SqmBinaryArithmetic.java | 9 ++++----- .../query/sqm/tree/expression/SqmUnaryOperation.java | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/TypecheckUtil.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/TypecheckUtil.java index 6a2e1e6afe..d1a0a5e077 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/TypecheckUtil.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/TypecheckUtil.java @@ -491,8 +491,8 @@ public class TypecheckUtil { } public static void assertOperable(SqmExpression left, SqmExpression right, BinaryArithmeticOperator op) { - final SqmExpressible leftNodeType = left.getNodeType(); - final SqmExpressible rightNodeType = right.getNodeType(); + final SqmExpressible leftNodeType = left.getExpressible(); + final SqmExpressible rightNodeType = right.getExpressible(); if ( leftNodeType != null && rightNodeType != null ) { final Class leftJavaType = leftNodeType.getRelationalJavaType().getJavaTypeClass(); final Class rightJavaType = rightNodeType.getRelationalJavaType().getJavaTypeClass(); @@ -628,7 +628,7 @@ public class TypecheckUtil { } public static void assertNumeric(SqmExpression expression, UnaryArithmeticOperator op) { - final SqmExpressible nodeType = expression.getNodeType(); + final SqmExpressible nodeType = expression.getExpressible(); if ( nodeType != null ) { if ( !( nodeType.getSqmType() instanceof JdbcMapping jdbcMapping ) || !jdbcMapping.getJdbcType().isNumber() ) { diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmBinaryArithmetic.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmBinaryArithmetic.java index b2cbdf75e5..3370403659 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmBinaryArithmetic.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmBinaryArithmetic.java @@ -12,7 +12,6 @@ import org.hibernate.query.sqm.SqmExpressible; import org.hibernate.query.sqm.tree.SqmCopyContext; import org.hibernate.query.sqm.tree.select.SqmSelectableNode; - import static org.hibernate.query.sqm.BinaryArithmeticOperator.ADD; import static org.hibernate.query.sqm.BinaryArithmeticOperator.SUBTRACT; import static org.hibernate.type.spi.TypeConfiguration.isDuration; @@ -34,8 +33,8 @@ public class SqmBinaryArithmetic extends AbstractSqmExpression implements //noinspection unchecked super( (SqmExpressible) domainModel.getTypeConfiguration().resolveArithmeticType( - lhsOperand.getNodeType(), - rhsOperand.getNodeType(), + lhsOperand.getExpressible(), + rhsOperand.getExpressible(), operator ), nodeBuilder @@ -49,8 +48,8 @@ public class SqmBinaryArithmetic extends AbstractSqmExpression implements ( operator == ADD || operator == SUBTRACT ) ) { return; } - this.lhsOperand.applyInferableType( rhsOperand.getNodeType() ); - this.rhsOperand.applyInferableType( lhsOperand.getNodeType() ); + this.lhsOperand.applyInferableType( rhsOperand.getExpressible() ); + this.rhsOperand.applyInferableType( lhsOperand.getExpressible() ); } public SqmBinaryArithmetic( diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmUnaryOperation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmUnaryOperation.java index d41f525640..66bbbcf2d9 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmUnaryOperation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmUnaryOperation.java @@ -22,7 +22,7 @@ public class SqmUnaryOperation extends AbstractSqmExpression implements Sq operation, operand, operand.nodeBuilder().getTypeConfiguration().getBasicTypeForJavaType( - operand.getNodeType().getRelationalJavaType().getJavaType() + operand.getExpressible().getRelationalJavaType().getJavaType() ) ); }