Skip to content

Commit

Permalink
add Expression.equalTo() and Expression.notEqualTo()
Browse files Browse the repository at this point in the history
see #438.
  • Loading branch information
gavinking authored and lukasj committed Aug 10, 2023
1 parent 4daf494 commit 2a40a58
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
33 changes: 33 additions & 0 deletions api/src/main/java/jakarta/persistence/criteria/Expression.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

// Contributors:
// Gavin King - 3.2
// Linda DeMichiel - 2.1
// Linda DeMichiel - 2.0

Expand Down Expand Up @@ -40,6 +41,38 @@ public interface Expression<T> extends Selection<T> {
*/
Predicate isNotNull();

/**
* Create a predicate to test whether the expression is equal to
* the argument.
* @param value expression to be tested against
* @return predicate testing for equality
*/
Predicate equalTo(Expression<?> value);

/**
* Create a predicate to test whether the expression is equal to
* the argument.
* @param value value to be tested against
* @return predicate testing for equality
*/
Predicate equalTo(Object value);

/**
* Create a predicate to test whether the expression is unequal
* to the argument.
* @param value expression to be tested against
* @return predicate testing for inequality
*/
Predicate notEqualTo(Expression<?> value);

/**
* Create a predicate to test whether the expression is unequal
* to the argument.
* @param value value to be tested against
* @return predicate testing for inequality
*/
Predicate notEqualTo(Object value);

/**
* Create a predicate to test whether the expression is a member
* of the argument list.
Expand Down
2 changes: 2 additions & 0 deletions spec/src/main/asciidoc/appendixes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ Added `||` string concatenation operator

Added _getSingleResultOrNull()_ to _Query_, _TypedQuery_, _StoredProcedureQuery_

Added _equalTo()_ and _notEqualTo()_ to _Expression_

Added _concat()_ overload accepting list of expressions to _CriteriaBuilder_

Made the _name_ member of _TableGenerator_ and _SequenceGenerator_ optional
Expand Down
32 changes: 32 additions & 0 deletions spec/src/main/asciidoc/ch06-criteria-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2767,6 +2767,38 @@ public interface Expression<T> extends Selection<T> {
*/
Predicate isNotNull();
/**
* Create a predicate to test whether the expression is equal to
* the argument.
* @param value expression to be tested against
* @return predicate testing for equality
*/
Predicate equalTo(Expression<?> value);
/**
* Create a predicate to test whether the expression is equal to
* the argument.
* @param value value to be tested against
* @return predicate testing for equality
*/
Predicate equalTo(Object value);
/**
* Create a predicate to test whether the expression is unequal
* to the argument.
* @param value expression to be tested against
* @return predicate testing for inequality
*/
Predicate notEqualTo(Expression<?> value);
/**
* Create a predicate to test whether the expression is unequal
* to the argument.
* @param value value to be tested against
* @return predicate testing for inequality
*/
Predicate notEqualTo(Object value);
/**
* Create a predicate to test whether the expression is a member
* of the argument list.
Expand Down

0 comments on commit 2a40a58

Please sign in to comment.