Skip to content

Commit

Permalink
HHH-18274 Properly resolving Java type in binary and unary expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
cigaly committed Nov 24, 2024
1 parent 73a8ff2 commit 4c6f568
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ else if ( !isTypeAssignable( targetType, expressionType, bindingContext) ) {
}

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();
Expand Down Expand Up @@ -628,7 +628,7 @@ public static void assertDuration(SqmExpression<?> expression) {
}

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() ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
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;
Expand All @@ -34,8 +33,8 @@ public SqmBinaryArithmetic(
//noinspection unchecked
super(
(SqmExpressible<T>) domainModel.getTypeConfiguration().resolveArithmeticType(
lhsOperand.getNodeType(),
rhsOperand.getNodeType(),
lhsOperand.getExpressible(),
rhsOperand.getExpressible(),
operator
),
nodeBuilder
Expand All @@ -49,8 +48,8 @@ public SqmBinaryArithmetic(
( 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public SqmUnaryOperation(UnaryArithmeticOperator operation, SqmExpression<T> ope
operation,
operand,
operand.nodeBuilder().getTypeConfiguration().getBasicTypeForJavaType(
operand.getNodeType().getRelationalJavaType().getJavaType()
operand.getExpressible().getRelationalJavaType().getJavaType()
)
);
}
Expand Down

0 comments on commit 4c6f568

Please sign in to comment.