HHH-18274 Properly resolving Java type in binary and unary expressions
This commit is contained in:
parent
63e90a3dcb
commit
aeb7601ac9
|
@ -491,8 +491,8 @@ public class TypecheckUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertOperable(SqmExpression<?> left, SqmExpression<?> right, BinaryArithmeticOperator op) {
|
public static void assertOperable(SqmExpression<?> left, SqmExpression<?> right, BinaryArithmeticOperator op) {
|
||||||
final SqmExpressible<?> leftNodeType = left.getNodeType();
|
final SqmExpressible<?> leftNodeType = left.getExpressible();
|
||||||
final SqmExpressible<?> rightNodeType = right.getNodeType();
|
final SqmExpressible<?> rightNodeType = right.getExpressible();
|
||||||
if ( leftNodeType != null && rightNodeType != null ) {
|
if ( leftNodeType != null && rightNodeType != null ) {
|
||||||
final Class<?> leftJavaType = leftNodeType.getRelationalJavaType().getJavaTypeClass();
|
final Class<?> leftJavaType = leftNodeType.getRelationalJavaType().getJavaTypeClass();
|
||||||
final Class<?> rightJavaType = rightNodeType.getRelationalJavaType().getJavaTypeClass();
|
final Class<?> rightJavaType = rightNodeType.getRelationalJavaType().getJavaTypeClass();
|
||||||
|
@ -628,7 +628,7 @@ public class TypecheckUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void assertNumeric(SqmExpression<?> expression, UnaryArithmeticOperator op) {
|
public static void assertNumeric(SqmExpression<?> expression, UnaryArithmeticOperator op) {
|
||||||
final SqmExpressible<?> nodeType = expression.getNodeType();
|
final SqmExpressible<?> nodeType = expression.getExpressible();
|
||||||
if ( nodeType != null ) {
|
if ( nodeType != null ) {
|
||||||
if ( !( nodeType.getSqmType() instanceof JdbcMapping jdbcMapping )
|
if ( !( nodeType.getSqmType() instanceof JdbcMapping jdbcMapping )
|
||||||
|| !jdbcMapping.getJdbcType().isNumber() ) {
|
|| !jdbcMapping.getJdbcType().isNumber() ) {
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.hibernate.query.sqm.SqmExpressible;
|
||||||
import org.hibernate.query.sqm.tree.SqmCopyContext;
|
import org.hibernate.query.sqm.tree.SqmCopyContext;
|
||||||
import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
|
import org.hibernate.query.sqm.tree.select.SqmSelectableNode;
|
||||||
|
|
||||||
|
|
||||||
import static org.hibernate.query.sqm.BinaryArithmeticOperator.ADD;
|
import static org.hibernate.query.sqm.BinaryArithmeticOperator.ADD;
|
||||||
import static org.hibernate.query.sqm.BinaryArithmeticOperator.SUBTRACT;
|
import static org.hibernate.query.sqm.BinaryArithmeticOperator.SUBTRACT;
|
||||||
import static org.hibernate.type.spi.TypeConfiguration.isDuration;
|
import static org.hibernate.type.spi.TypeConfiguration.isDuration;
|
||||||
|
@ -34,8 +33,8 @@ public class SqmBinaryArithmetic<T> extends AbstractSqmExpression<T> implements
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
super(
|
super(
|
||||||
(SqmExpressible<T>) domainModel.getTypeConfiguration().resolveArithmeticType(
|
(SqmExpressible<T>) domainModel.getTypeConfiguration().resolveArithmeticType(
|
||||||
lhsOperand.getNodeType(),
|
lhsOperand.getExpressible(),
|
||||||
rhsOperand.getNodeType(),
|
rhsOperand.getExpressible(),
|
||||||
operator
|
operator
|
||||||
),
|
),
|
||||||
nodeBuilder
|
nodeBuilder
|
||||||
|
@ -49,8 +48,8 @@ public class SqmBinaryArithmetic<T> extends AbstractSqmExpression<T> implements
|
||||||
( operator == ADD || operator == SUBTRACT ) ) {
|
( operator == ADD || operator == SUBTRACT ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.lhsOperand.applyInferableType( rhsOperand.getNodeType() );
|
this.lhsOperand.applyInferableType( rhsOperand.getExpressible() );
|
||||||
this.rhsOperand.applyInferableType( lhsOperand.getNodeType() );
|
this.rhsOperand.applyInferableType( lhsOperand.getExpressible() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public SqmBinaryArithmetic(
|
public SqmBinaryArithmetic(
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class SqmUnaryOperation<T> extends AbstractSqmExpression<T> implements Sq
|
||||||
operation,
|
operation,
|
||||||
operand,
|
operand,
|
||||||
operand.nodeBuilder().getTypeConfiguration().getBasicTypeForJavaType(
|
operand.nodeBuilder().getTypeConfiguration().getBasicTypeForJavaType(
|
||||||
operand.getNodeType().getRelationalJavaType().getJavaType()
|
operand.getExpressible().getRelationalJavaType().getJavaType()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue