From dfb268ae2aea199d4d88bb9d94cda218b95fdd74 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 30 Jul 2024 16:39:54 +0200 Subject: [PATCH] HHH-18448 Add cast and notEqualTo methods to JpaExpression and SqmExpression --- .../java/org/hibernate/query/criteria/JpaExpression.java | 7 +++++++ .../hql/internal/FullyQualifiedReflectivePathTerminal.java | 2 +- .../hibernate/query/sqm/tree/expression/SqmExpression.java | 5 +++++ .../query/sqm/tree/expression/SqmFieldLiteral.java | 2 +- .../org/hibernate/query/sqm/tree/select/SqmSubQuery.java | 2 +- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaExpression.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaExpression.java index e8e731c5a6..6692ec27ad 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/JpaExpression.java @@ -60,5 +60,12 @@ public interface JpaExpression extends JpaSelection, Expression { @Override Predicate equalTo(Object value); + @Override JpaExpression cast(Class type); + + @Override + Predicate notEqualTo(Expression value); + + @Override + Predicate notEqualTo(Object value); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/FullyQualifiedReflectivePathTerminal.java b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/FullyQualifiedReflectivePathTerminal.java index 1ab797ad93..9d82573a68 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/hql/internal/FullyQualifiedReflectivePathTerminal.java +++ b/hibernate-core/src/main/java/org/hibernate/query/hql/internal/FullyQualifiedReflectivePathTerminal.java @@ -236,7 +236,7 @@ public class FullyQualifiedReflectivePathTerminal } @Override - public Expression cast(Class type) { + public SqmExpression cast(Class type) { return null; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmExpression.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmExpression.java index 408cd7fa29..d5938301cf 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmExpression.java @@ -131,4 +131,9 @@ public interface SqmExpression extends SqmSelectableNode, JpaExpression return castAs( nodeBuilder().getTypeConfiguration().getBasicTypeForJavaType( type ) ); } + @Override + Predicate notEqualTo(Expression value); + + @Override + Predicate notEqualTo(Object value); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmFieldLiteral.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmFieldLiteral.java index 12e0a064e0..673fdccd48 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmFieldLiteral.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmFieldLiteral.java @@ -175,7 +175,7 @@ public class SqmFieldLiteral implements SqmExpression, SqmExpressible, } @Override - public Expression cast(Class type) { + public SqmExpression cast(Class type) { return null; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/select/SqmSubQuery.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/select/SqmSubQuery.java index 88d72de8df..33d2458d0b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/select/SqmSubQuery.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/select/SqmSubQuery.java @@ -731,7 +731,7 @@ public class SqmSubQuery extends AbstractSqmSelectQuery implements SqmSele } @Override - public Expression cast(Class targetType) { + public SqmExpression cast(Class targetType) { return nodeBuilder().cast( this, targetType ); }