Interface Expression<T>

Type Parameters:
T - the type of the expression
All Superinterfaces:
Selection<T>, TupleElement<T>
All Known Subinterfaces:
BooleanExpression, BooleanPath, CollectionJoin<Z,E>, ComparableExpression<C>, CriteriaBuilder.Case<R>, CriteriaBuilder.Coalesce<T>, CriteriaBuilder.In<T>, CriteriaBuilder.SimpleCase<C,R>, From<Z,X>, Join<Z,X>, ListJoin<Z,E>, MapJoin<Z,K,V>, NumericExpression<N>, ParameterExpression<T>, Path<X>, PluralExpression<C,E>, PluralJoin<Z,C,E>, Predicate, Root<X>, SetJoin<Z,E>, Subquery<T>, TemporalExpression<T>, TextExpression

public interface Expression<T> extends Selection<T>
Type for query expressions.
Since:
2.0
  • Method Details

    • isNull

      @Nonnull Predicate isNull()
      Create a predicate to test whether the expression is null.
      Returns:
      predicate testing whether the expression is null
    • isNotNull

      @Nonnull Predicate isNotNull()
      Create a predicate to test whether the expression is not null.
      Returns:
      predicate testing whether the expression is not null
    • equalTo

      @Nonnull Predicate equalTo(@Nonnull Expression<?> value)
      Create a predicate to test whether the expression is equal to the argument.
      Parameters:
      value - expression to be tested against
      Returns:
      predicate testing for equality
      Since:
      3.2
    • equalTo

      @Nonnull Predicate equalTo(Object value)
      Create a predicate to test whether the expression is equal to the argument.
      Parameters:
      value - value to be tested against
      Returns:
      predicate testing for equality
      Since:
      3.2
    • notEqualTo

      @Nonnull Predicate notEqualTo(@Nonnull Expression<?> value)
      Create a predicate to test whether the expression is unequal to the argument.
      Parameters:
      value - expression to be tested against
      Returns:
      predicate testing for inequality
      Since:
      3.2
    • notEqualTo

      @Nonnull Predicate notEqualTo(Object value)
      Create a predicate to test whether the expression is unequal to the argument.
      Parameters:
      value - value to be tested against
      Returns:
      predicate testing for inequality
      Since:
      3.2
    • in

      @Nonnull Predicate in(@Nonnull Object... values)
      Create a predicate to test whether the expression is a member of the argument list.
      Parameters:
      values - values to be tested against
      Returns:
      predicate testing for membership
    • in

      @Nonnull Predicate in(@Nonnull Expression<?>... values)
      Create a predicate to test whether the expression is a member of the argument list.
      Parameters:
      values - expressions to be tested against
      Returns:
      predicate testing for membership
    • in

      @Nonnull Predicate in(@Nonnull Collection<?> values)
      Create a predicate to test whether the expression is a member of the collection.
      Parameters:
      values - collection of values to be tested against
      Returns:
      predicate testing for membership
    • in

      @Nonnull Predicate in(@Nonnull Expression<Collection<?>> values)
      Create a predicate to test whether the expression is a member of the collection.
      Parameters:
      values - expression corresponding to collection to be tested against
      Returns:
      predicate testing for membership
    • in

      @Nonnull Predicate in(@Nonnull Subquery<T> subquery)
      Create a predicate to test whether the expression is returned by the subquery.
      Parameters:
      subquery - the subquery
      Returns:
      predicate testing for membership
      Since:
      4.0
    • as

      @Nonnull <X> Expression<X> as(@Nonnull Class<X> type)
      Perform a typecast upon the expression, returning a new expression object. Unlike cast(Class), this method does not cause type conversion: the runtime type is not changed.

      Warning: may result in a runtime failure.

      Type Parameters:
      X - the intended type of the expression
      Parameters:
      type - intended type of the expression
      Returns:
      new expression of the given type
      See Also:
    • cast

      @Nonnull <X> Expression<X> cast(@Nonnull Class<X> type)
      Cast this expression to the specified type, returning a new expression object. Unlike as(Class), this method does result in a runtime type conversion.

      Providers are required to support casting scalar expressions to String, and String expressions to Integer, Long, Float, and Double. Support for typecasts between other basic types is not required.

      Type Parameters:
      X - the target type of the cast
      Parameters:
      type - a basic type
      Returns:
      a scalar expression of the given basic type
      Since:
      3.2
    • coalesce

      @Nonnull Expression<T> coalesce(@Nonnull Expression<? extends T> y)
      Create an expression that returns null if this and the argument evaluate to null, and the value of the first non-null expression otherwise.
      Parameters:
      y - expression
      Returns:
      coalesce expression
      Since:
      4.0
    • coalesce

      @Nonnull Expression<T> coalesce(T y)
      Create an expression that returns null if this and the argument evaluate to null, and the value of the first non-null expression otherwise.
      Parameters:
      y - value
      Returns:
      coalesce expression
      Since:
      4.0
    • nullif

      @Nonnull Expression<T> nullif(@Nonnull Expression<? extends T> y)
      Create an expression that tests whether this expression is equal to the argument, returning null if they are and the value of the first expression if they are not.
      Parameters:
      y - expression
      Returns:
      nullif expression
      Since:
      4.0
    • nullif

      @Nonnull Expression<T> nullif(T y)
      Create an expression that tests whether this expression is equal to the argument, returning null if they are and the value of the first expression if they are not.
      Parameters:
      y - value
      Returns:
      nullif expression
      Since:
      4.0
    • selectCase

      @Nonnull <R> CriteriaBuilder.SimpleCase<T,R> selectCase(@Nonnull Class<R> type)
      Create a simple case expression to test against this expression.
      Type Parameters:
      R - the result type of the case expression
      Parameters:
      type - the type of the result of the case expression
      Returns:
      simple case expression
      Since:
      4.0
    • isMember

      @Nonnull Predicate isMember(@Nonnull Expression<? extends Collection<? super T>> collection)
      Create a predicate that tests whether this expression is a member of a collection. If the collection is empty, the predicate will be false.
      Parameters:
      collection - expression
      Returns:
      is-member predicate
      Since:
      4.0
    • isNotMember

      @Nonnull Predicate isNotMember(@Nonnull Expression<? extends Collection<? super T>> collection)
      Create a predicate that tests whether this expression is not a member of a collection. If the collection is empty, the predicate will be true.
      Parameters:
      collection - expression
      Returns:
      is-not-member predicate
      Since:
      4.0
    • count

      @Nonnull NumericExpression<Long> count()
      Create an aggregate expression applying the count operation.
      Returns:
      count expression
      Since:
      4.0
    • countDistinct

      @Nonnull NumericExpression<Long> countDistinct()
      Create an aggregate expression applying the count distinct operation.
      Returns:
      count distinct expression
      Since:
      4.0