HHH-16898 add JpaExpression.equalTo()

This commit is contained in:
Gavin King 2023-07-05 18:12:40 +02:00
parent d7fd5bd78a
commit a440046556
6 changed files with 51 additions and 2 deletions

View File

@ -52,4 +52,8 @@ public interface JpaExpression<T> extends JpaSelection<T>, Expression<T> {
@Override
JpaPredicate in(Expression<Collection<?>> values);
JpaPredicate equalTo(Expression<T> that);
JpaPredicate equalTo(T that);
}

View File

@ -207,6 +207,16 @@ public class FullyQualifiedReflectivePathTerminal
return null;
}
@Override
public SqmPredicate equalTo(Expression that) {
return null;
}
@Override
public SqmPredicate equalTo(Object that) {
return null;
}
@Override
public SqmPredicate in(Object... values) {
return null;

View File

@ -23,7 +23,6 @@ import org.hibernate.type.descriptor.java.JavaType;
import jakarta.persistence.criteria.Expression;
import static org.hibernate.query.internal.QueryHelper.highestPrecedenceType;
import static org.hibernate.query.internal.QueryHelper.highestPrecedenceType2;
/**
@ -115,6 +114,16 @@ public abstract class AbstractSqmExpression<T> extends AbstractJpaSelection<T> i
return nodeBuilder().isNotNull( this );
}
@Override
public SqmPredicate equalTo(Expression<T> that) {
return nodeBuilder().equal( this, that );
}
@Override
public SqmPredicate equalTo(T that) {
return nodeBuilder().equal( this, that );
}
@Override
public SqmPredicate in(Object... values) {
return nodeBuilder().in( this, values );

View File

@ -36,7 +36,7 @@ import static java.util.Arrays.asList;
public interface SqmExpression<T> extends SqmSelectableNode<T>, JpaExpression<T> {
/**
* The expression's type.
*
* <p>
* Can change as a result of calls to {@link #applyInferableType}
*/
@Override
@ -92,6 +92,12 @@ public interface SqmExpression<T> extends SqmSelectableNode<T>, JpaExpression<T>
@Override
SqmPredicate isNotNull();
@Override
SqmPredicate equalTo(Expression<T> that);
@Override
SqmPredicate equalTo(T that);
@Override
SqmPredicate in(Object... values);

View File

@ -152,6 +152,16 @@ public class SqmFieldLiteral<T> implements SqmExpression<T>, SqmExpressible<T>,
return nodeBuilder().isNull( this );
}
@Override
public SqmPredicate equalTo(Expression<T> that) {
return nodeBuilder().equal( this, that );
}
@Override
public SqmPredicate equalTo(T that) {
return nodeBuilder().equal( this, that );
}
@Override
public SqmPredicate isNotNull() {
return nodeBuilder().isNotNull( this );

View File

@ -560,6 +560,16 @@ public class SqmSubQuery<T> extends AbstractSqmSelectQuery<T> implements SqmSele
return nodeBuilder().isNotNull( this );
}
@Override
public SqmPredicate equalTo(Expression<T> that) {
return nodeBuilder().equal( this, that );
}
@Override
public SqmPredicate equalTo(T that) {
return nodeBuilder().equal( this, that );
}
@Override
public SqmInPredicate<?> in(Object... values) {
return nodeBuilder().in( this, values );