Interface CriteriaBuilder


public interface CriteriaBuilder
Used to construct criteria queries, compound selections, expressions, predicates, orderings.

Note that Predicate is used instead of Expression<Boolean> in this API in order to work around the fact that Java generics are not compatible with varags.

Since:
2.0
  • Method Details

    • createQuery

      @Nonnull CriteriaQuery<Object> createQuery()
      Create a CriteriaQuery object.
      Returns:
      criteria query object
    • createQuery

      @Nonnull <T> CriteriaQuery<T> createQuery(@Nonnull Class<T> resultClass)
      Create a CriteriaQuery object with the given result type.
      Type Parameters:
      T - the query result type
      Parameters:
      resultClass - type of the query result
      Returns:
      criteria query object
    • createQuery

      @Nonnull <T> CriteriaQuery<T> createQuery(@Nonnull Class<T> resultClass, @Nonnull String jpql)
      Create a CriteriaQuery object representing the given Jakarta Persistence query language SELECT query with the given result type.
      Type Parameters:
      T - the query result type
      Parameters:
      resultClass - type of the query result
      jpql - A Jakarta Persistence query language SELECT query
      Returns:
      criteria query object
      Throws:
      IllegalArgumentException - if the query string is found to be invalid, or if the query result is found to not be assignable to the specified type and the specified type does not have a suitable constructor
      Since:
      4.0
    • createQuery

      @Nonnull CriteriaQuery<?> createQuery(@Nonnull String jpql)
      Create a CriteriaQuery object representing the given Jakarta Persistence query language SELECT query.
      Parameters:
      jpql - A Jakarta Persistence query language SELECT query
      Returns:
      criteria query object
      Throws:
      IllegalArgumentException - if the query string is found to be invalid
      Since:
      4.0
    • createTupleQuery

      @Nonnull CriteriaQuery<Tuple> createTupleQuery()
      Create a CriteriaQuery object that returns a tuple of objects as its result.
      Returns:
      criteria query object
    • createCriteriaUpdate

      @Nonnull <T> CriteriaUpdate<T> createCriteriaUpdate(@Nonnull Class<T> targetEntity)
      Create a CriteriaUpdate object to perform a bulk update operation.
      Type Parameters:
      T - the target entity type
      Parameters:
      targetEntity - target type for update operation
      Returns:
      the criteria statement object
      Since:
      2.1
    • createCriteriaUpdate

      @Nonnull <T> CriteriaUpdate<T> createCriteriaUpdate(@Nonnull Class<T> targetEntity, @Nonnull String jpql)
      Create a CriteriaUpdate object representing the given Jakarta Persistence query language UPDATE query with the given target entity type.
      Type Parameters:
      T - the target entity type
      Parameters:
      targetEntity - target type for update operation
      jpql - A Jakarta Persistence query language UPDATE query
      Returns:
      the criteria statement object
      Throws:
      IllegalArgumentException - if the query string is found to be invalid, or if the entity type updated by the query is not exactly the same as the specified target type
      Since:
      4.0
    • createCriteriaUpdate

      @Nonnull CriteriaUpdate<?> createCriteriaUpdate(@Nonnull String jpql)
      Create a CriteriaUpdate object representing the given Jakarta Persistence query language UPDATE query.
      Parameters:
      jpql - A Jakarta Persistence query language UPDATE query
      Returns:
      the criteria statement object
      Throws:
      IllegalArgumentException - if the query string is found to be invalid
      Since:
      4.0
    • createCriteriaDelete

      @Nonnull <T> CriteriaDelete<T> createCriteriaDelete(@Nonnull Class<T> targetEntity)
      Create a CriteriaDelete object to perform a bulk delete operation.
      Type Parameters:
      T - the target entity type
      Parameters:
      targetEntity - target type for delete operation
      Returns:
      the criteria statement object
      Since:
      2.1
    • createCriteriaDelete

      @Nonnull <T> CriteriaDelete<T> createCriteriaDelete(@Nonnull Class<T> targetEntity, @Nonnull String jpql)
      Create a CriteriaDelete object representing the given Jakarta Persistence query language DELETE query with the given target entity type.
      Type Parameters:
      T - the target entity type
      Parameters:
      targetEntity - target type for delete operation
      jpql - A Jakarta Persistence query language DELETE query
      Returns:
      the criteria statement object
      Throws:
      IllegalArgumentException - if the query string is found to be invalid, or if the entity type deleted by the query is not exactly the same as the specified target type
      Since:
      4.0
    • createCriteriaDelete

      @Nonnull CriteriaDelete<?> createCriteriaDelete(@Nonnull String jpql)
      Create a CriteriaDelete object representing the given Jakarta Persistence query language DELETE query.
      Parameters:
      jpql - A Jakarta Persistence query language DELETE query
      Returns:
      the criteria statement object
      Throws:
      IllegalArgumentException - if the query string is found to be invalid
      Since:
      4.0
    • augment

      @Nonnull <T> TypedQueryReference<T> augment(@Nonnull TypedQueryReference<T> reference, @Nonnull Consumer<CriteriaQuery<T>> augmentation)
      Modify the Jakarta Persistence query language query represented by the given reference, returning a reference to the modified query inheriting all the options of the given reference. This operation never modifies the query represented by the given reference.
      Type Parameters:
      T - the query result type
      Parameters:
      reference - A reference to a Jakarta Persistence query language SELECT query
      augmentation - a consumer that modifies the query
      Returns:
      a reference to the modified query
      Throws:
      IllegalArgumentException - if the given reference does not represent a named Jakarta Persistence query language SELECT query belonging to the owning factory
      Since:
      4.0
    • augment

      @Nonnull StatementReference augment(@Nonnull StatementReference reference, @Nonnull Consumer<CriteriaStatement<?>> augmentation)
      Modify the Jakarta Persistence query language statement represented by the given reference, returning a reference to the modified statement inheriting all the options of the given reference. This operation never modifies the query represented by the given reference.
      Parameters:
      reference - A reference to a Jakarta Persistence query language statement
      augmentation - a consumer that modifies the statement
      Returns:
      a reference to the modified statement
      Throws:
      IllegalArgumentException - if the given reference does not represent a named Jakarta Persistence query language statement belonging to the owning factory
      Since:
      4.0
    • construct

      @Nonnull <Y> CompoundSelection<Y> construct(@Nonnull Class<Y> resultClass, @Nonnull Selection<?>... selections)
      Create a selection item corresponding to a constructor. This method is used to specify a constructor that is applied to the results of the query execution. If the constructor is for an entity class, the resulting entities will be in the new state after the query is executed.
      Type Parameters:
      Y - the type of the constructed result
      Parameters:
      resultClass - class whose instance is to be constructed
      selections - arguments to the constructor
      Returns:
      compound selection item
      Throws:
      IllegalArgumentException - if an argument is a tuple- or array-valued selection item
    • tuple

      @Nonnull CompoundSelection<Tuple> tuple(@Nonnull Selection<?>... selections)
      Create a tuple-valued selection item.
      Parameters:
      selections - selection items
      Returns:
      tuple-valued compound selection
      Throws:
      IllegalArgumentException - if an argument is a tuple- or array-valued selection item
    • tuple

      @Nonnull CompoundSelection<Tuple> tuple(@Nonnull List<Selection<?>> selections)
      Create a tuple-valued selection item.
      Parameters:
      selections - list of selection items
      Returns:
      tuple-valued compound selection
      Throws:
      IllegalArgumentException - if an argument is a tuple- or array-valued selection item
      Since:
      3.2
    • array

      @Nonnull CompoundSelection<Object[]> array(@Nonnull Selection<?>... selections)
      Create an array-valued selection item.
      Parameters:
      selections - selection items
      Returns:
      array-valued compound selection
      Throws:
      IllegalArgumentException - if an argument is a tuple- or array-valued selection item
    • array

      @Nonnull CompoundSelection<Object[]> array(@Nonnull List<Selection<?>> selections)
      Create an array-valued selection item.
      Parameters:
      selections - list of selection items
      Returns:
      array-valued compound selection
      Throws:
      IllegalArgumentException - if an argument is a tuple- or array-valued selection item
      Since:
      3.2
    • asc

      @Nonnull Order asc(@Nonnull Expression<?> expression)
      Create an ordering by the ascending value of the expression.
      Parameters:
      expression - expression used to define the ordering
      Returns:
      ascending ordering corresponding to the expression
    • desc

      @Nonnull Order desc(@Nonnull Expression<?> expression)
      Create an ordering by the descending value of the expression.
      Parameters:
      expression - expression used to define the ordering
      Returns:
      descending ordering corresponding to the expression
    • asc

      @Nonnull Order asc(@Nonnull Expression<?> expression, @Nonnull Nulls nullPrecedence)
      Create an ordering by the ascending value of the expression.
      Parameters:
      expression - expression used to define the ordering
      nullPrecedence - the precedence of null values
      Returns:
      ascending ordering corresponding to the expression
      Since:
      3.2
    • desc

      @Nonnull Order desc(@Nonnull Expression<?> expression, @Nonnull Nulls nullPrecedence)
      Create an ordering by the descending value of the expression.
      Parameters:
      expression - expression used to define the ordering
      nullPrecedence - the precedence of null values
      Returns:
      descending ordering corresponding to the expression
      Since:
      3.2
    • avg

      @Nonnull <N extends Number> Expression<Double> avg(@Nonnull Expression<N> x)
      Create an aggregate expression applying the avg operation.
      Type Parameters:
      N - the numeric type of the expression
      Parameters:
      x - expression representing input value to avg operation
      Returns:
      avg expression
    • sum

      @Nonnull <N extends Number> Expression<N> sum(@Nonnull Expression<N> x)
      Create an aggregate expression applying the sum operation.
      Type Parameters:
      N - the numeric type of the expression
      Parameters:
      x - expression representing input value to sum operation
      Returns:
      sum expression
    • sumAsLong

      @Nonnull Expression<Long> sumAsLong(@Nonnull Expression<Integer> x)
      Create an aggregate expression applying the sum operation to an Integer-valued expression, returning a Long result.
      Parameters:
      x - expression representing input value to sum operation
      Returns:
      sum expression
    • sumAsDouble

      @Nonnull Expression<Double> sumAsDouble(@Nonnull Expression<Float> x)
      Create an aggregate expression applying the sum operation to a Float-valued expression, returning a Double result.
      Parameters:
      x - expression representing input value to sum operation
      Returns:
      sum expression
    • max

      @Nonnull <N extends Number> Expression<N> max(@Nonnull Expression<N> x)
      Create an aggregate expression applying the numerical max operation.
      Type Parameters:
      N - the numeric type of the expression
      Parameters:
      x - expression representing input value to max operation
      Returns:
      max expression
    • min

      @Nonnull <N extends Number> Expression<N> min(@Nonnull Expression<N> x)
      Create an aggregate expression applying the numerical min operation.
      Type Parameters:
      N - the numeric type of the expression
      Parameters:
      x - expression representing input value to min operation
      Returns:
      min expression
    • greatest

      @Nonnull <X extends Comparable<? super X>> Expression<X> greatest(@Nonnull Expression<X> x)
      Create an aggregate expression for finding the greatest of the values (strings, dates, etc).
      Type Parameters:
      X - the type of the expression
      Parameters:
      x - expression representing input value to greatest operation
      Returns:
      greatest expression
    • least

      @Nonnull <X extends Comparable<? super X>> Expression<X> least(@Nonnull Expression<X> x)
      Create an aggregate expression for finding the least of the values (strings, dates, etc).
      Type Parameters:
      X - the type of the expression
      Parameters:
      x - expression representing input value to least operation
      Returns:
      least expression
    • count

      @Nonnull Expression<Long> count(@Nonnull Expression<?> x)
      Create an aggregate expression applying the count operation.
      Parameters:
      x - expression representing input value to count operation
      Returns:
      count expression
    • countDistinct

      @Nonnull Expression<Long> countDistinct(@Nonnull Expression<?> x)
      Create an aggregate expression applying the count distinct operation.
      Parameters:
      x - expression representing input value to count distinct operation
      Returns:
      count distinct expression
    • exists

      @Nonnull Predicate exists(@Nonnull Subquery<?> subquery)
      Create a predicate testing the existence of a subquery result.
      Parameters:
      subquery - subquery whose result is to be tested
      Returns:
      exists predicate
    • all

      @Nonnull <Y> Expression<Y> all(@Nonnull Subquery<Y> subquery)
      Create an all expression over the subquery results.
      Type Parameters:
      Y - the subquery result type
      Parameters:
      subquery - subquery
      Returns:
      all expression
    • some

      @Nonnull <Y> Expression<Y> some(@Nonnull Subquery<Y> subquery)
      Create a some expression over the subquery results. This expression is equivalent to an any expression.
      Type Parameters:
      Y - the subquery result type
      Parameters:
      subquery - subquery
      Returns:
      some expression
    • any

      @Nonnull <Y> Expression<Y> any(@Nonnull Subquery<Y> subquery)
      Create an any expression over the subquery results. This expression is equivalent to a some expression.
      Type Parameters:
      Y - the subquery result type
      Parameters:
      subquery - subquery
      Returns:
      any expression
    • and

      @Nonnull Predicate and(@Nonnull Expression<Boolean> x, @Nonnull Expression<Boolean> y)
      Create a conjunction of the given boolean expressions.
      Parameters:
      x - boolean expression
      y - boolean expression
      Returns:
      and predicate
    • and

      @Nonnull Predicate and(@Nonnull BooleanExpression... restrictions)
      Create a conjunction of the given restriction predicates. A conjunction of zero predicates is true.
      Parameters:
      restrictions - zero or more restriction predicates
      Returns:
      and predicate
    • and

      @Nonnull Predicate and(@Nonnull List<? extends Expression<Boolean>> restrictions)
      Create a conjunction of the given restriction predicates. A conjunction of zero predicates is true.
      Parameters:
      restrictions - a list of zero or more restriction predicates
      Returns:
      and predicate
      Since:
      3.2
    • or

      @Nonnull Predicate or(@Nonnull Expression<Boolean> x, @Nonnull Expression<Boolean> y)
      Create a disjunction of the given boolean expressions.
      Parameters:
      x - boolean expression
      y - boolean expression
      Returns:
      or predicate
    • or

      @Nonnull Predicate or(@Nonnull BooleanExpression... restrictions)
      Create a disjunction of the given restriction predicates. A disjunction of zero predicates is false.
      Parameters:
      restrictions - zero or more restriction predicates
      Returns:
      or predicate
    • or

      @Nonnull Predicate or(@Nonnull List<? extends Expression<Boolean>> restrictions)
      Create a disjunction of the given restriction predicates. A disjunction of zero predicates is false.
      Parameters:
      restrictions - a list of zero or more restriction predicates
      Returns:
      or predicate
      Since:
      3.2
    • not

      @Nonnull Predicate not(@Nonnull Expression<Boolean> restriction)
      Create a negation of the given restriction.
      Parameters:
      restriction - restriction expression
      Returns:
      not predicate
    • conjunction

      @Nonnull Predicate conjunction()
      Create a conjunction (with zero conjuncts). A conjunction with zero conjuncts is true.
      Returns:
      and predicate
    • disjunction

      @Nonnull Predicate disjunction()
      Create a disjunction (with zero disjuncts). A disjunction with zero disjuncts is false.
      Returns:
      or predicate
    • isTrue

      @Nonnull Predicate isTrue(@Nonnull Expression<Boolean> x)
      Create a predicate testing for a true value.
      Parameters:
      x - expression to be tested
      Returns:
      predicate
    • isFalse

      @Nonnull Predicate isFalse(@Nonnull Expression<Boolean> x)
      Create a predicate testing for a false value.
      Parameters:
      x - expression to be tested
      Returns:
      predicate
    • isNull

      @Nonnull Predicate isNull(@Nonnull Expression<?> x)
      Create a predicate to test whether the expression is null.
      Parameters:
      x - expression
      Returns:
      is-null predicate
    • isNotNull

      @Nonnull Predicate isNotNull(@Nonnull Expression<?> x)
      Create a predicate to test whether the expression is not null.
      Parameters:
      x - expression
      Returns:
      is-not-null predicate
    • equal

      @Nonnull Predicate equal(@Nonnull Expression<?> x, @Nonnull Expression<?> y)
      Create a predicate for testing the arguments for equality.
      Parameters:
      x - expression
      y - expression
      Returns:
      equality predicate
    • equal

      @Nonnull Predicate equal(@Nonnull Expression<?> x, Object y)
      Create a predicate for testing the arguments for equality.
      Parameters:
      x - expression
      y - object
      Returns:
      equality predicate
    • notEqual

      @Nonnull Predicate notEqual(@Nonnull Expression<?> x, @Nonnull Expression<?> y)
      Create a predicate for testing the arguments for inequality.
      Parameters:
      x - expression
      y - expression
      Returns:
      inequality predicate
    • notEqual

      @Nonnull Predicate notEqual(@Nonnull Expression<?> x, Object y)
      Create a predicate for testing the arguments for inequality.
      Parameters:
      x - expression
      y - object
      Returns:
      inequality predicate
    • greaterThan

      @Nonnull <Y extends Comparable<? super Y>> Predicate greaterThan(@Nonnull Expression<? extends Y> x, @Nonnull Expression<? extends Y> y)
      Create a predicate for testing whether the first argument is greater than the second.
      Type Parameters:
      Y - the type of the compared expressions
      Parameters:
      x - expression
      y - expression
      Returns:
      greater-than predicate
      See Also:
    • greaterThan

      @Nonnull <Y extends Comparable<? super Y>> Predicate greaterThan(@Nonnull Expression<? extends Y> x, Y y)
      Create a predicate for testing whether the first argument is greater than the second.
      Type Parameters:
      Y - the type of the compared values
      Parameters:
      x - expression
      y - value
      Returns:
      greater-than predicate
      See Also:
    • greaterThanOrEqualTo

      @Nonnull <Y extends Comparable<? super Y>> Predicate greaterThanOrEqualTo(@Nonnull Expression<? extends Y> x, @Nonnull Expression<? extends Y> y)
      Create a predicate for testing whether the first argument is greater than or equal to the second.
      Type Parameters:
      Y - the type of the compared expressions
      Parameters:
      x - expression
      y - expression
      Returns:
      greater-than-or-equal predicate
      See Also:
    • greaterThanOrEqualTo

      @Nonnull <Y extends Comparable<? super Y>> Predicate greaterThanOrEqualTo(@Nonnull Expression<? extends Y> x, Y y)
      Create a predicate for testing whether the first argument is greater than or equal to the second.
      Type Parameters:
      Y - the type of the compared values
      Parameters:
      x - expression
      y - value
      Returns:
      greater-than-or-equal predicate
      See Also:
    • lessThan

      @Nonnull <Y extends Comparable<? super Y>> Predicate lessThan(@Nonnull Expression<? extends Y> x, @Nonnull Expression<? extends Y> y)
      Create a predicate for testing whether the first argument is less than the second.
      Type Parameters:
      Y - the type of the compared expressions
      Parameters:
      x - expression
      y - expression
      Returns:
      less-than predicate
      See Also:
    • lessThan

      @Nonnull <Y extends Comparable<? super Y>> Predicate lessThan(@Nonnull Expression<? extends Y> x, Y y)
      Create a predicate for testing whether the first argument is less than the second.
      Type Parameters:
      Y - the type of the compared values
      Parameters:
      x - expression
      y - value
      Returns:
      less-than predicate
      See Also:
    • lessThanOrEqualTo

      @Nonnull <Y extends Comparable<? super Y>> Predicate lessThanOrEqualTo(@Nonnull Expression<? extends Y> x, @Nonnull Expression<? extends Y> y)
      Create a predicate for testing whether the first argument is less than or equal to the second.
      Type Parameters:
      Y - the type of the compared expressions
      Parameters:
      x - expression
      y - expression
      Returns:
      less-than-or-equal predicate
      See Also:
    • lessThanOrEqualTo

      @Nonnull <Y extends Comparable<? super Y>> Predicate lessThanOrEqualTo(@Nonnull Expression<? extends Y> x, Y y)
      Create a predicate for testing whether the first argument is less than or equal to the second.
      Type Parameters:
      Y - the type of the compared values
      Parameters:
      x - expression
      y - value
      Returns:
      less-than-or-equal predicate
      See Also:
    • between

      @Nonnull <Y extends Comparable<? super Y>> Predicate between(@Nonnull Expression<? extends Y> v, @Nonnull Expression<? extends Y> x, @Nonnull Expression<? extends Y> y)
      Create a predicate for testing whether the first argument is between the second and third arguments in value.
      Type Parameters:
      Y - the type of the compared expressions
      Parameters:
      v - expression
      x - expression
      y - expression
      Returns:
      between predicate
    • between

      @Nonnull <Y extends Comparable<? super Y>> Predicate between(@Nonnull Expression<? extends Y> v, Y x, Y y)
      Create a predicate for testing whether the first argument is between the second and third arguments in value.
      Type Parameters:
      Y - the type of the compared values
      Parameters:
      v - expression
      x - value
      y - value
      Returns:
      between predicate
    • between

      @Nonnull <Y extends Comparable<? super Y>> Predicate between(Y v, @Nonnull Expression<? extends Y> x, @Nonnull Expression<? extends Y> y)
      Create a predicate for testing whether the first argument is between the second and third arguments in value.
      Type Parameters:
      Y - the type of the compared values
      Parameters:
      v - value
      x - expression
      y - expression
      Returns:
      between predicate
      Since:
      4.0
    • gt

      @Nonnull Predicate gt(@Nonnull Expression<? extends Number> x, @Nonnull Expression<? extends Number> y)
      Create a predicate for testing whether the first argument is greater than the second. This operation accepts arguments of heterogeneous numeric types.
      Parameters:
      x - expression
      y - expression
      Returns:
      greater-than predicate
    • gt

      @Nonnull Predicate gt(@Nonnull Expression<? extends Number> x, Number y)
      Create a predicate for testing whether the first argument is greater than the second. This operation accepts arguments of heterogeneous numeric types.
      Parameters:
      x - expression
      y - value
      Returns:
      greater-than predicate
    • ge

      @Nonnull Predicate ge(@Nonnull Expression<? extends Number> x, @Nonnull Expression<? extends Number> y)
      Create a predicate for testing whether the first argument is greater than or equal to the second. This operation accepts arguments of heterogeneous numeric types.
      Parameters:
      x - expression
      y - expression
      Returns:
      greater-than-or-equal predicate
    • ge

      @Nonnull Predicate ge(@Nonnull Expression<? extends Number> x, Number y)
      Create a predicate for testing whether the first argument is greater than or equal to the second. This operation accepts arguments of heterogeneous numeric types.
      Parameters:
      x - expression
      y - value
      Returns:
      greater-than-or-equal predicate
    • lt

      @Nonnull Predicate lt(@Nonnull Expression<? extends Number> x, @Nonnull Expression<? extends Number> y)
      Create a predicate for testing whether the first argument is less than the second. This operation accepts arguments of heterogeneous numeric types.
      Parameters:
      x - expression
      y - expression
      Returns:
      less-than predicate
    • lt

      @Nonnull Predicate lt(@Nonnull Expression<? extends Number> x, Number y)
      Create a predicate for testing whether the first argument is less than the second. This operation accepts arguments of heterogeneous numeric types.
      Parameters:
      x - expression
      y - value
      Returns:
      less-than predicate
    • le

      @Nonnull Predicate le(@Nonnull Expression<? extends Number> x, @Nonnull Expression<? extends Number> y)
      Create a predicate for testing whether the first argument is less than or equal to the second. This operation accepts arguments of heterogeneous numeric types.
      Parameters:
      x - expression
      y - expression
      Returns:
      less-than-or-equal predicate
    • le

      @Nonnull Predicate le(@Nonnull Expression<? extends Number> x, Number y)
      Create a predicate for testing whether the first argument is less than or equal to the second. This operation accepts arguments of heterogeneous numeric types.
      Parameters:
      x - expression
      y - value
      Returns:
      less-than-or-equal predicate
    • sign

      @Nonnull Expression<Integer> sign(@Nonnull Expression<? extends Number> x)
      Create an expression that returns the sign of its argument, that is, 1 if its argument is positive, -1 if its argument is negative, or 0 if its argument is exactly zero.
      Parameters:
      x - expression
      Returns:
      sign
    • neg

      @Nonnull <N extends Number> Expression<N> neg(@Nonnull Expression<N> x)
      Create an expression that returns the arithmetic negation of its argument.
      Type Parameters:
      N - the numeric type of the expression
      Parameters:
      x - expression
      Returns:
      arithmetic negation
    • abs

      @Nonnull <N extends Number> Expression<N> abs(@Nonnull Expression<N> x)
      Create an expression that returns the absolute value of its argument.
      Type Parameters:
      N - the numeric type of the expression
      Parameters:
      x - expression
      Returns:
      absolute value
    • ceiling

      @Nonnull <N extends Number> Expression<N> ceiling(@Nonnull Expression<N> x)
      Create an expression that returns the ceiling of its argument, that is, the smallest integer greater than or equal to its argument.
      Type Parameters:
      N - the numeric type of the expression
      Parameters:
      x - expression
      Returns:
      ceiling
    • floor

      @Nonnull <N extends Number> Expression<N> floor(@Nonnull Expression<N> x)
      Create an expression that returns the floor of its argument, that is, the largest integer smaller than or equal to its argument.
      Type Parameters:
      N - the numeric type of the expression
      Parameters:
      x - expression
      Returns:
      floor
    • sum

      @Nonnull <N extends Number> Expression<N> sum(@Nonnull Expression<? extends N> x, @Nonnull Expression<? extends N> y)
      Create an expression that returns the sum of its arguments.
      Type Parameters:
      N - the numeric type of the expressions
      Parameters:
      x - expression
      y - expression
      Returns:
      sum
    • sum

      @Nonnull <N extends Number> Expression<N> sum(@Nonnull Expression<? extends N> x, N y)
      Create an expression that returns the sum of its arguments.
      Type Parameters:
      N - the numeric type of the arguments
      Parameters:
      x - expression
      y - value
      Returns:
      sum
    • sum

      @Nonnull <N extends Number> Expression<N> sum(N x, @Nonnull Expression<? extends N> y)
      Create an expression that returns the sum of its arguments.
      Type Parameters:
      N - the numeric type of the arguments
      Parameters:
      x - value
      y - expression
      Returns:
      sum
    • prod

      @Nonnull <N extends Number> Expression<N> prod(@Nonnull Expression<? extends N> x, @Nonnull Expression<? extends N> y)
      Create an expression that returns the product of its arguments.
      Type Parameters:
      N - the numeric type of the expressions
      Parameters:
      x - expression
      y - expression
      Returns:
      product
    • prod

      @Nonnull <N extends Number> Expression<N> prod(@Nonnull Expression<? extends N> x, N y)
      Create an expression that returns the product of its arguments.
      Type Parameters:
      N - the numeric type of the arguments
      Parameters:
      x - expression
      y - value
      Returns:
      product
    • prod

      @Nonnull <N extends Number> Expression<N> prod(N x, @Nonnull Expression<? extends N> y)
      Create an expression that returns the product of its arguments.
      Type Parameters:
      N - the numeric type of the arguments
      Parameters:
      x - value
      y - expression
      Returns:
      product
    • diff

      @Nonnull <N extends Number> Expression<N> diff(@Nonnull Expression<? extends N> x, @Nonnull Expression<? extends N> y)
      Create an expression that returns the difference between its arguments.
      Type Parameters:
      N - the numeric type of the expressions
      Parameters:
      x - expression
      y - expression
      Returns:
      difference
    • diff

      @Nonnull <N extends Number> Expression<N> diff(@Nonnull Expression<? extends N> x, N y)
      Create an expression that returns the difference between its arguments.
      Type Parameters:
      N - the numeric type of the arguments
      Parameters:
      x - expression
      y - value
      Returns:
      difference
    • diff

      @Nonnull <N extends Number> Expression<N> diff(N x, @Nonnull Expression<? extends N> y)
      Create an expression that returns the difference between its arguments.
      Type Parameters:
      N - the numeric type of the arguments
      Parameters:
      x - value
      y - expression
      Returns:
      difference
    • quot

      @Nonnull Expression<Number> quot(@Nonnull Expression<? extends Number> x, @Nonnull Expression<? extends Number> y)
      Create an expression that returns the quotient of its arguments.
      Parameters:
      x - expression
      y - expression
      Returns:
      quotient
    • quot

      @Nonnull Expression<Number> quot(@Nonnull Expression<? extends Number> x, Number y)
      Create an expression that returns the quotient of its arguments.
      Parameters:
      x - expression
      y - value
      Returns:
      quotient
    • quot

      @Nonnull Expression<Number> quot(Number x, @Nonnull Expression<? extends Number> y)
      Create an expression that returns the quotient of its arguments.
      Parameters:
      x - value
      y - expression
      Returns:
      quotient
    • mod

      @Nonnull Expression<Integer> mod(@Nonnull Expression<Integer> x, @Nonnull Expression<Integer> y)
      Create an expression that returns the modulus (remainder under integer division) of its arguments.
      Parameters:
      x - expression
      y - expression
      Returns:
      modulus
    • mod

      @Nonnull Expression<Integer> mod(@Nonnull Expression<Integer> x, Integer y)
      Create an expression that returns the modulus (remainder under integer division) of its arguments.
      Parameters:
      x - expression
      y - value
      Returns:
      modulus
    • mod

      @Nonnull Expression<Integer> mod(Integer x, @Nonnull Expression<Integer> y)
      Create an expression that returns the modulus (remainder under integer division) of its arguments.
      Parameters:
      x - value
      y - expression
      Returns:
      modulus
    • sqrt

      @Nonnull Expression<Double> sqrt(@Nonnull Expression<? extends Number> x)
      Create an expression that returns the square root of its argument.
      Parameters:
      x - expression
      Returns:
      square root
    • exp

      @Nonnull Expression<Double> exp(@Nonnull Expression<? extends Number> x)
      Create an expression that returns the exponential of its argument, that is, Euler's number e raised to the power of its argument.
      Parameters:
      x - expression
      Returns:
      exponential
    • ln

      @Nonnull Expression<Double> ln(@Nonnull Expression<? extends Number> x)
      Create an expression that returns the natural logarithm of its argument.
      Parameters:
      x - expression
      Returns:
      natural logarithm
    • power

      @Nonnull Expression<Double> power(@Nonnull Expression<? extends Number> x, @Nonnull Expression<? extends Number> y)
      Create an expression that returns the first argument raised to the power of its second argument.
      Parameters:
      x - base
      y - exponent
      Returns:
      the base raised to the power of the exponent
    • power

      @Nonnull Expression<Double> power(@Nonnull Expression<? extends Number> x, Number y)
      Create an expression that returns the first argument raised to the power of its second argument.
      Parameters:
      x - base
      y - exponent
      Returns:
      the base raised to the power of the exponent
    • round

      @Nonnull <T extends Number> Expression<T> round(@Nonnull Expression<T> x, @Nonnull Integer n)
      Create an expression that returns the first argument rounded to the number of decimal places given by the second argument.
      Type Parameters:
      T - the numeric type of the expression
      Parameters:
      x - base
      n - number of decimal places
      Returns:
      the rounded value
    • toLong

      @Nonnull Expression<Long> toLong(@Nonnull Expression<? extends Number> number)
      Typecast.
      Parameters:
      number - numeric expression
      Returns:
      Expression<Long>
    • toInteger

      @Nonnull Expression<Integer> toInteger(@Nonnull Expression<? extends Number> number)
      Typecast.
      Parameters:
      number - numeric expression
      Returns:
      Expression<Integer>
    • toFloat

      @Nonnull Expression<Float> toFloat(@Nonnull Expression<? extends Number> number)
      Typecast.
      Parameters:
      number - numeric expression
      Returns:
      Expression<Float>
    • toDouble

      @Nonnull Expression<Double> toDouble(@Nonnull Expression<? extends Number> number)
      Typecast.
      Parameters:
      number - numeric expression
      Returns:
      Expression<Double>
    • toBigDecimal

      @Nonnull Expression<BigDecimal> toBigDecimal(@Nonnull Expression<? extends Number> number)
      Typecast.
      Parameters:
      number - numeric expression
      Returns:
      Expression<BigDecimal>
    • toBigInteger

      @Nonnull Expression<BigInteger> toBigInteger(@Nonnull Expression<? extends Number> number)
      Typecast.
      Parameters:
      number - numeric expression
      Returns:
      Expression<BigInteger>
    • toString

      @Nonnull Expression<String> toString(@Nonnull Expression<Character> character)
      Typecast.
      Parameters:
      character - expression
      Returns:
      Expression<String>
    • literal

      @Nonnull <T> Expression<T> literal(@Nonnull T value)
      Create an expression for a literal.
      Type Parameters:
      T - the type of the literal value
      Parameters:
      value - value represented by the expression
      Returns:
      expression literal
      Throws:
      IllegalArgumentException - if value is null
    • numericLiteral

      @Nonnull <N extends Number & Comparable<N>> NumericExpression<N> numericLiteral(@Nonnull N value)
      Create a number expression for a literal.
      Type Parameters:
      N - the numeric type of the literal value
      Parameters:
      value - value represented by the expression
      Returns:
      expression literal
      Throws:
      IllegalArgumentException - if value is null
      Since:
      4.0
    • stringLiteral

      @Nonnull TextExpression stringLiteral(@Nonnull String value)
      Create a string expression for a literal.
      Parameters:
      value - value represented by the expression
      Returns:
      expression literal
      Throws:
      IllegalArgumentException - if value is null
      Since:
      4.0
    • temporalLiteral

      @Nonnull <T extends Temporal & Comparable<? super T>> TemporalExpression<T> temporalLiteral(@Nonnull T value)
      Create a local date expression for a literal.
      Type Parameters:
      T - the temporal type of the literal value
      Parameters:
      value - value represented by the expression
      Returns:
      expression literal
      Throws:
      IllegalArgumentException - if value is null
      Since:
      4.0
    • booleanLiteral

      @Nonnull BooleanExpression booleanLiteral(boolean value)
      Create a boolean expression for a literal.
      Returns:
      expression literal
      Since:
      4.0
    • nullLiteral

      @Nonnull <T> Expression<T> nullLiteral(@Nonnull Class<T> resultClass)
      Create an expression for a null literal with the given type.
      Type Parameters:
      T - the type of the null literal
      Parameters:
      resultClass - type of the null literal
      Returns:
      null expression literal
    • parameter

      @Nonnull <T> ParameterExpression<T> parameter(@Nonnull Class<T> paramClass)
      Create a parameter expression.
      Type Parameters:
      T - the parameter type
      Parameters:
      paramClass - parameter class
      Returns:
      parameter expression
    • parameter

      @Nonnull <T> ParameterExpression<T> parameter(@Nonnull Class<T> paramClass, @Nonnull String name)
      Create a parameter expression with the given name.
      Type Parameters:
      T - the parameter type
      Parameters:
      paramClass - parameter class
      name - name that can be used to refer to the parameter
      Returns:
      parameter expression
    • convertedParameter

      @Nonnull <T> ParameterExpression<T> convertedParameter(@Nonnull Class<? extends AttributeConverter<T,?>> converter)
      Create a parameter expression whose value is bound via a converter.
      Type Parameters:
      T - the parameter type
      Parameters:
      converter - the class of the attribute converter
      Returns:
      parameter expression
      Since:
      4.0
    • isEmpty

      @Nonnull <C extends Collection<?>> Predicate isEmpty(@Nonnull Expression<C> collection)
      Create a predicate that tests whether a collection is empty.
      Type Parameters:
      C - the collection type
      Parameters:
      collection - expression
      Returns:
      is-empty predicate
    • isNotEmpty

      @Nonnull <C extends Collection<?>> Predicate isNotEmpty(@Nonnull Expression<C> collection)
      Create a predicate that tests whether a collection is not empty.
      Type Parameters:
      C - the collection type
      Parameters:
      collection - expression
      Returns:
      is-not-empty predicate
    • size

      @Nonnull <C extends Collection<?>> Expression<Integer> size(@Nonnull Expression<C> collection)
      Create an expression that tests the size of a collection.
      Type Parameters:
      C - the collection type
      Parameters:
      collection - expression
      Returns:
      size expression
    • size

      @Nonnull <C extends Collection<?>> Expression<Integer> size(@Nonnull C collection)
      Create an expression that tests the size of a collection.
      Type Parameters:
      C - the collection type
      Parameters:
      collection - collection
      Returns:
      size expression
    • isMember

      @Nonnull <E, C extends Collection<E>> Predicate isMember(@Nonnull Expression<E> elem, @Nonnull Expression<C> collection)
      Create a predicate that tests whether an element is a member of a collection. If the collection is empty, the predicate will be false.
      Type Parameters:
      E - the element type
      C - the collection type
      Parameters:
      elem - element expression
      collection - expression
      Returns:
      is-member predicate
    • isMember

      @Nonnull <E, C extends Collection<E>> Predicate isMember(E elem, @Nonnull Expression<C> collection)
      Create a predicate that tests whether an element is a member of a collection. If the collection is empty, the predicate will be false.
      Type Parameters:
      E - the element type
      C - the collection type
      Parameters:
      elem - element
      collection - expression
      Returns:
      is-member predicate
    • isNotMember

      @Nonnull <E, C extends Collection<E>> Predicate isNotMember(@Nonnull Expression<E> elem, @Nonnull Expression<C> collection)
      Create a predicate that tests whether an element is not a member of a collection. If the collection is empty, the predicate will be true.
      Type Parameters:
      E - the element type
      C - the collection type
      Parameters:
      elem - element expression
      collection - expression
      Returns:
      is-not-member predicate
    • isNotMember

      @Nonnull <E, C extends Collection<E>> Predicate isNotMember(E elem, @Nonnull Expression<C> collection)
      Create a predicate that tests whether an element is not a member of a collection. If the collection is empty, the predicate will be true.
      Type Parameters:
      E - the element type
      C - the collection type
      Parameters:
      elem - element
      collection - expression
      Returns:
      is-not-member predicate
    • like

      @Nonnull Predicate like(@Nonnull Expression<String> x, @Nonnull Expression<String> pattern)
      Create a predicate for testing whether the expression satisfies the given pattern.
      Parameters:
      x - string expression
      pattern - string expression
      Returns:
      like predicate
    • like

      @Nonnull Predicate like(@Nonnull Expression<String> x, @Nonnull String pattern)
      Create a predicate for testing whether the expression satisfies the given pattern.
      Parameters:
      x - string expression
      pattern - string
      Returns:
      like predicate
    • like

      @Nonnull Predicate like(@Nonnull Expression<String> x, @Nonnull Expression<String> pattern, @Nonnull Expression<Character> escapeChar)
      Create a predicate for testing whether the expression satisfies the given pattern.
      Parameters:
      x - string expression
      pattern - string expression
      escapeChar - escape character expression
      Returns:
      like predicate
    • like

      @Nonnull Predicate like(@Nonnull Expression<String> x, @Nonnull Expression<String> pattern, char escapeChar)
      Create a predicate for testing whether the expression satisfies the given pattern.
      Parameters:
      x - string expression
      pattern - string expression
      escapeChar - escape character
      Returns:
      like predicate
    • like

      @Nonnull Predicate like(@Nonnull Expression<String> x, @Nonnull String pattern, @Nonnull Expression<Character> escapeChar)
      Create a predicate for testing whether the expression satisfies the given pattern.
      Parameters:
      x - string expression
      pattern - string
      escapeChar - escape character expression
      Returns:
      like predicate
    • like

      @Nonnull Predicate like(@Nonnull Expression<String> x, @Nonnull String pattern, char escapeChar)
      Create a predicate for testing whether the expression satisfies the given pattern.
      Parameters:
      x - string expression
      pattern - string
      escapeChar - escape character
      Returns:
      like predicate
    • notLike

      @Nonnull Predicate notLike(@Nonnull Expression<String> x, @Nonnull Expression<String> pattern)
      Create a predicate for testing whether the expression does not satisfy the given pattern.
      Parameters:
      x - string expression
      pattern - string expression
      Returns:
      not-like predicate
    • notLike

      @Nonnull Predicate notLike(@Nonnull Expression<String> x, @Nonnull String pattern)
      Create a predicate for testing whether the expression does not satisfy the given pattern.
      Parameters:
      x - string expression
      pattern - string
      Returns:
      not-like predicate
    • notLike

      @Nonnull Predicate notLike(@Nonnull Expression<String> x, @Nonnull Expression<String> pattern, @Nonnull Expression<Character> escapeChar)
      Create a predicate for testing whether the expression does not satisfy the given pattern.
      Parameters:
      x - string expression
      pattern - string expression
      escapeChar - escape character expression
      Returns:
      not-like predicate
    • notLike

      @Nonnull Predicate notLike(@Nonnull Expression<String> x, @Nonnull Expression<String> pattern, char escapeChar)
      Create a predicate for testing whether the expression does not satisfy the given pattern.
      Parameters:
      x - string expression
      pattern - string expression
      escapeChar - escape character
      Returns:
      not-like predicate
    • notLike

      @Nonnull Predicate notLike(@Nonnull Expression<String> x, @Nonnull String pattern, @Nonnull Expression<Character> escapeChar)
      Create a predicate for testing whether the expression does not satisfy the given pattern.
      Parameters:
      x - string expression
      pattern - string
      escapeChar - escape character expression
      Returns:
      not-like predicate
    • notLike

      @Nonnull Predicate notLike(@Nonnull Expression<String> x, @Nonnull String pattern, char escapeChar)
      Create a predicate for testing whether the expression does not satisfy the given pattern.
      Parameters:
      x - string expression
      pattern - string
      escapeChar - escape character
      Returns:
      not-like predicate
    • concat

      @Nonnull Expression<String> concat(@Nonnull List<Expression<String>> expressions)
      Create an expression for string concatenation. If the given list of expressions is empty, returns an expression equivalent to literal("").
      Parameters:
      expressions - string expressions
      Returns:
      expression corresponding to concatenation
    • concat

      @Nonnull Expression<String> concat(@Nonnull Expression<String> x, @Nonnull Expression<String> y)
      Create an expression for string concatenation.
      Parameters:
      x - string expression
      y - string expression
      Returns:
      expression corresponding to concatenation
    • concat

      @Nonnull Expression<String> concat(@Nonnull Expression<String> x, @Nonnull String y)
      Create an expression for string concatenation.
      Parameters:
      x - string expression
      y - string
      Returns:
      expression corresponding to concatenation
    • concat

      @Nonnull Expression<String> concat(@Nonnull String x, @Nonnull Expression<String> y)
      Create an expression for string concatenation.
      Parameters:
      x - string
      y - string expression
      Returns:
      expression corresponding to concatenation
    • substring

      @Nonnull Expression<String> substring(@Nonnull Expression<String> x, @Nonnull Expression<Integer> from)
      Create an expression for substring extraction. Extracts a substring starting at the specified position through to end of the string. First position is 1.
      Parameters:
      x - string expression
      from - start position expression
      Returns:
      expression corresponding to substring extraction
    • substring

      @Nonnull Expression<String> substring(@Nonnull Expression<String> x, int from)
      Create an expression for substring extraction. Extracts a substring starting at the specified position through to end of the string. First position is 1.
      Parameters:
      x - string expression
      from - start position
      Returns:
      expression corresponding to substring extraction
    • substring

      @Nonnull Expression<String> substring(@Nonnull Expression<String> x, @Nonnull Expression<Integer> from, @Nonnull Expression<Integer> len)
      Create an expression for substring extraction. Extracts a substring of given length starting at the specified position. First position is 1.
      Parameters:
      x - string expression
      from - start position expression
      len - length expression
      Returns:
      expression corresponding to substring extraction
    • substring

      @Nonnull Expression<String> substring(@Nonnull Expression<String> x, int from, int len)
      Create an expression for substring extraction. Extracts a substring of given length starting at the specified position. First position is 1.
      Parameters:
      x - string expression
      from - start position
      len - length
      Returns:
      expression corresponding to substring extraction
    • trim

      @Nonnull Expression<String> trim(@Nonnull Expression<String> x)
      Create expression to trim blanks from both ends of a string.
      Parameters:
      x - expression for string to trim
      Returns:
      trim expression
    • trim

      @Nonnull Expression<String> trim(@Nonnull CriteriaBuilder.Trimspec ts, @Nonnull Expression<String> x)
      Create expression to trim blanks from a string.
      Parameters:
      ts - trim specification
      x - expression for string to trim
      Returns:
      trim expression
    • trim

      @Nonnull Expression<String> trim(@Nonnull Expression<Character> t, @Nonnull Expression<String> x)
      Create expression to trim character from both ends of a string.
      Parameters:
      t - expression for character to be trimmed
      x - expression for string to trim
      Returns:
      trim expression
    • trim

      @Nonnull Expression<String> trim(@Nonnull CriteriaBuilder.Trimspec ts, @Nonnull Expression<Character> t, @Nonnull Expression<String> x)
      Create expression to trim character from a string.
      Parameters:
      ts - trim specification
      t - expression for character to be trimmed
      x - expression for string to trim
      Returns:
      trim expression
    • trim

      @Nonnull Expression<String> trim(char t, @Nonnull Expression<String> x)
      Create expression to trim character from both ends of a string.
      Parameters:
      t - character to be trimmed
      x - expression for string to trim
      Returns:
      trim expression
    • trim

      @Nonnull Expression<String> trim(@Nonnull CriteriaBuilder.Trimspec ts, char t, @Nonnull Expression<String> x)
      Create expression to trim character from a string.
      Parameters:
      ts - trim specification
      t - character to be trimmed
      x - expression for string to trim
      Returns:
      trim expression
    • lower

      @Nonnull Expression<String> lower(@Nonnull Expression<String> x)
      Create expression for converting a string to lowercase.
      Parameters:
      x - string expression
      Returns:
      expression to convert to lowercase
    • upper

      @Nonnull Expression<String> upper(@Nonnull Expression<String> x)
      Create expression for converting a string to uppercase.
      Parameters:
      x - string expression
      Returns:
      expression to convert to uppercase
    • length

      @Nonnull Expression<Integer> length(@Nonnull Expression<String> x)
      Create expression to return length of a string.
      Parameters:
      x - string expression
      Returns:
      length expression
    • left

      @Nonnull Expression<String> left(@Nonnull Expression<String> x, int len)
      Create an expression for the leftmost substring of a string,
      Parameters:
      x - string expression
      len - length of the substring to return
      Returns:
      expression for the leftmost substring
    • right

      @Nonnull Expression<String> right(@Nonnull Expression<String> x, int len)
      Create an expression for the rightmost substring of a string,
      Parameters:
      x - string expression
      len - length of the substring to return
      Returns:
      expression for the rightmost substring
    • left

      @Nonnull Expression<String> left(@Nonnull Expression<String> x, @Nonnull Expression<Integer> len)
      Create an expression for the leftmost substring of a string,
      Parameters:
      x - string expression
      len - length of the substring to return
      Returns:
      expression for the leftmost substring
    • right

      @Nonnull Expression<String> right(@Nonnull Expression<String> x, @Nonnull Expression<Integer> len)
      Create an expression for the rightmost substring of a string,
      Parameters:
      x - string expression
      len - length of the substring to return
      Returns:
      expression for the rightmost substring
    • replace

      @Nonnull Expression<String> replace(@Nonnull Expression<String> x, @Nonnull Expression<String> substring, @Nonnull Expression<String> replacement)
      Create an expression replacing every occurrence of a substring within a string.
      Parameters:
      x - string expression
      substring - the literal substring to replace
      replacement - the replacement string
      Returns:
      expression for the resulting string
    • replace

      @Nonnull Expression<String> replace(@Nonnull Expression<String> x, @Nonnull String substring, @Nonnull Expression<String> replacement)
      Create an expression replacing every occurrence of a substring within a string.
      Parameters:
      x - string expression
      substring - the literal substring to replace
      replacement - the replacement string
      Returns:
      expression for the resulting string
    • replace

      @Nonnull Expression<String> replace(@Nonnull Expression<String> x, @Nonnull Expression<String> substring, @Nonnull String replacement)
      Create an expression replacing every occurrence of a substring within a string.
      Parameters:
      x - string expression
      substring - the literal substring to replace
      replacement - the replacement string
      Returns:
      expression for the resulting string
    • replace

      @Nonnull Expression<String> replace(@Nonnull Expression<String> x, @Nonnull String substring, @Nonnull String replacement)
      Create an expression replacing every occurrence of a substring within a string.
      Parameters:
      x - string expression
      substring - the literal substring to replace
      replacement - the replacement string
      Returns:
      expression for the resulting string
    • locate

      @Nonnull Expression<Integer> locate(@Nonnull Expression<String> x, @Nonnull Expression<String> pattern)
      Create expression to locate the position of one string within another, returning position of first character if found. The first position in a string is denoted by 1. If the string to be located is not found, 0 is returned.

      Warning: the order of the parameters of this method is reversed compared to the corresponding function in JPQL.

      Parameters:
      x - expression for string to be searched
      pattern - expression for string to be located
      Returns:
      expression corresponding to position
    • locate

      @Nonnull Expression<Integer> locate(@Nonnull Expression<String> x, @Nonnull String pattern)
      Create expression to locate the position of one string within another, returning position of first character if found. The first position in a string is denoted by 1. If the string to be located is not found, 0 is returned.

      Warning: the order of the parameters of this method is reversed compared to the corresponding function in JPQL.

      Parameters:
      x - expression for string to be searched
      pattern - string to be located
      Returns:
      expression corresponding to position
    • locate

      @Nonnull Expression<Integer> locate(@Nonnull Expression<String> x, @Nonnull Expression<String> pattern, @Nonnull Expression<Integer> from)
      Create expression to locate the position of one string within another, returning position of first character if found. The first position in a string is denoted by 1. If the string to be located is not found, 0 is returned.

      Warning: the order of the first two parameters of this method is reversed compared to the corresponding function in JPQL.

      Parameters:
      x - expression for string to be searched
      pattern - expression for string to be located
      from - expression for position at which to start search
      Returns:
      expression corresponding to position
    • locate

      @Nonnull Expression<Integer> locate(@Nonnull Expression<String> x, @Nonnull String pattern, int from)
      Create expression to locate the position of one string within another, returning position of first character if found. The first position in a string is denoted by 1. If the string to be located is not found, 0 is returned.

      Warning: the order of the first two parameters of this method is reversed compared to the corresponding function in JPQL.

      Parameters:
      x - expression for string to be searched
      pattern - string to be located
      from - position at which to start search
      Returns:
      expression corresponding to position
    • currentDate

      @Nonnull Expression<Date> currentDate()
      Create expression to return current date.
      Returns:
      expression for current date
    • currentTimestamp

      @Nonnull Expression<Timestamp> currentTimestamp()
      Create expression to return current timestamp.
      Returns:
      expression for current timestamp
    • currentTime

      @Nonnull Expression<Time> currentTime()
      Create expression to return current time.
      Returns:
      expression for current time
    • localDate

      @Nonnull Expression<LocalDate> localDate()
      Create expression to return current local date.
      Returns:
      expression for current date
    • localDateTime

      @Nonnull Expression<LocalDateTime> localDateTime()
      Create expression to return current local datetime.
      Returns:
      expression for current timestamp
    • localTime

      @Nonnull Expression<LocalTime> localTime()
      Create expression to return current local time.
      Returns:
      expression for current time
    • extract

      @Nonnull <N, T extends Temporal> Expression<N> extract(@Nonnull TemporalField<N,T> field, @Nonnull Expression<T> temporal)
      Create an expression that returns the value of a field extracted from a date, time, or datetime.
      Type Parameters:
      N - the type of the extracted value
      T - the temporal type
      Parameters:
      field - a temporal field type
      temporal - a date, time, or datetime
      Returns:
      expression for the value of the extracted field
      Since:
      3.2
    • in

      @Nonnull <T> CriteriaBuilder.In<T> in(@Nonnull Expression<? extends T> expression)
      Create predicate to test whether given expression is contained in a list of values.
      Type Parameters:
      T - the type of the expression
      Parameters:
      expression - to be tested against list of values
      Returns:
      in predicate
    • coalesce

      @Nonnull <Y> Expression<Y> coalesce(@Nonnull Expression<? extends Y> x, @Nonnull Expression<? extends Y> y)
      Create an expression that returns null if all its arguments evaluate to null, and the value of the first non-null argument otherwise.
      Type Parameters:
      Y - the type of the expression
      Parameters:
      x - expression
      y - expression
      Returns:
      coalesce expression
    • coalesce

      @Nonnull <Y> Expression<Y> coalesce(@Nonnull Expression<? extends Y> x, Y y)
      Create an expression that returns null if all its arguments evaluate to null, and the value of the first non-null argument otherwise.
      Type Parameters:
      Y - the type of the expression
      Parameters:
      x - expression
      y - value
      Returns:
      coalesce expression
    • nullif

      @Nonnull <Y> Expression<Y> nullif(@Nonnull Expression<Y> x, @Nonnull Expression<?> y)
      Create an expression that tests whether its argument are equal, returning null if they are and the value of the first expression if they are not.
      Type Parameters:
      Y - the type of the expression
      Parameters:
      x - expression
      y - expression
      Returns:
      nullif expression
    • nullif

      @Nonnull <Y> Expression<Y> nullif(@Nonnull Expression<Y> x, Y y)
      Create an expression that tests whether its argument are equal, returning null if they are and the value of the first expression if they are not.
      Type Parameters:
      Y - the type of the expression
      Parameters:
      x - expression
      y - value
      Returns:
      nullif expression
    • coalesce

      @Nonnull <T> CriteriaBuilder.Coalesce<T> coalesce()
      Create a coalesce expression.
      Type Parameters:
      T - the type of the coalesce expression
      Returns:
      coalesce expression
    • selectCase

      @Nonnull <C,R> CriteriaBuilder.SimpleCase<C,R> selectCase(@Nonnull Expression<? extends C> expression, @Nonnull Class<R> type)
      Create a simple case expression.
      Parameters:
      expression - to be tested against the case conditions
      type - the type of the result of the case expression
      Returns:
      simple case expression
    • selectCase

      @Deprecated(since="4.0") @Nonnull <C,R> CriteriaBuilder.SimpleCase<C,R> selectCase(@Nonnull Expression<? extends C> expression)
      Deprecated.
      This operation declares an unconstrained type variable. Use selectCase(Expression,Class) instead.
      Create a simple case expression.
      Type Parameters:
      C - the type of the case expression
      R - the result type of the case expression
      Parameters:
      expression - to be tested against the case conditions
      Returns:
      simple case expression
    • selectCase

      @Nonnull <R> CriteriaBuilder.Case<R> selectCase(@Nonnull Class<R> type)
      Create a general case expression.
      Parameters:
      type - the type of the result of the case expression
      Returns:
      general case expression
    • selectCase

      @Deprecated(since="4.0") @Nonnull <R> CriteriaBuilder.Case<R> selectCase()
      Deprecated.
      This operation declares an unconstrained type variable. Use selectCase(Class) instead.
      Create a general case expression.
      Type Parameters:
      R - the result type of the case expression
      Returns:
      general case expression
    • function

      @Nonnull <T> Expression<T> function(@Nonnull String name, @Nonnull Class<T> type, @Nonnull Expression<?>... args)
      Create an expression for the execution of the database function with the given name.
      Type Parameters:
      T - the function result type
      Parameters:
      name - function name
      type - expected result type
      args - function arguments
      Returns:
      expression
      API note:
      This operation allows invocation of arbitrary SQL functions. The persistence provider is permitted to pass the given function name verbatim to the database, with no additional validation or sanitization. Therefore, the client must never pass unvalidated user input nor any other untrusted string value to the first parameter of this method.
    • treat

      @Nonnull <X, T, V extends T> Join<X,V> treat(@Nonnull Join<X,T> join, @Nonnull Class<V> type)
      Downcast Join object to the specified type.
      Type Parameters:
      X - the source type of the join
      T - the target type of the join
      V - the subtype to treat the join as
      Parameters:
      join - Join object
      type - type to be downcast to
      Returns:
      Join object of the specified type
      Since:
      2.1
    • treat

      @Nonnull <X, T, E extends T> CollectionJoin<X,E> treat(@Nonnull CollectionJoin<X,T> join, @Nonnull Class<E> type)
      Downcast CollectionJoin object to the specified type.
      Type Parameters:
      X - the source type of the join
      T - the element type of the join
      E - the subtype to treat the join as
      Parameters:
      join - CollectionJoin object
      type - type to be downcast to
      Returns:
      CollectionJoin object of the specified type
      Since:
      2.1
    • treat

      @Nonnull <X, T, E extends T> SetJoin<X,E> treat(@Nonnull SetJoin<X,T> join, @Nonnull Class<E> type)
      Downcast SetJoin object to the specified type.
      Type Parameters:
      X - the source type of the join
      T - the element type of the join
      E - the subtype to treat the join as
      Parameters:
      join - SetJoin object
      type - type to be downcast to
      Returns:
      SetJoin object of the specified type
      Since:
      2.1
    • treat

      @Nonnull <X, T, E extends T> ListJoin<X,E> treat(@Nonnull ListJoin<X,T> join, @Nonnull Class<E> type)
      Downcast ListJoin object to the specified type.
      Type Parameters:
      X - the source type of the join
      T - the element type of the join
      E - the subtype to treat the join as
      Parameters:
      join - ListJoin object
      type - type to be downcast to
      Returns:
      ListJoin object of the specified type
      Since:
      2.1
    • treat

      @Nonnull <X, K, T, V extends T> MapJoin<X,K,V> treat(@Nonnull MapJoin<X,K,T> join, @Nonnull Class<V> type)
      Downcast MapJoin object to the specified type.
      Type Parameters:
      X - the source type of the join
      K - the key type of the join
      T - the value type of the join
      V - the subtype to treat the join as
      Parameters:
      join - MapJoin object
      type - type to be downcast to
      Returns:
      MapJoin object of the specified type
      Since:
      2.1
    • treat

      @Nonnull <X, T extends X> Path<T> treat(@Nonnull Path<X> path, @Nonnull Class<T> type)
      Downcast Path object to the specified type.
      Type Parameters:
      X - the type of the path
      T - the subtype to treat the path as
      Parameters:
      path - path
      type - type to be downcast to
      Returns:
      Path object of the specified type
      Since:
      2.1
    • treat

      @Nonnull <X, Y, T extends Y> From<X,T> treat(@Nonnull From<X,Y> from, @Nonnull Class<T> type)
      Downcast Root or Join to the specified type.
      Type Parameters:
      X - the source type
      Y - the target type
      T - the subtype to treat the root or join as
      Parameters:
      from - root or join
      type - type to be downcast to
      Returns:
      Root or Join of the specified type
      Since:
      4.0
    • treat

      @Nonnull <X, T extends X> Root<T> treat(@Nonnull Root<X> root, @Nonnull Class<T> type)
      Downcast Root object to the specified type.
      Type Parameters:
      X - the type of the root
      T - the subtype to treat the root as
      Parameters:
      root - root
      type - type to be downcast to
      Returns:
      Root object of the specified type
      Since:
      2.1
    • union

      @Nonnull <T> CriteriaSelect<T> union(@Nonnull CriteriaSelect<? extends T> left, @Nonnull CriteriaSelect<? extends T> right)
      Create a query which is the union of the given queries.
      Type Parameters:
      T - the result type of the query
      Returns:
      a new criteria query which returns the union of the results of the given queries
      Since:
      3.2
    • unionAll

      @Nonnull <T> CriteriaSelect<T> unionAll(@Nonnull CriteriaSelect<? extends T> left, @Nonnull CriteriaSelect<? extends T> right)
      Create a query which is the union of the given queries, without elimination of duplicate results.
      Type Parameters:
      T - the result type of the query
      Returns:
      a new criteria query which returns the union of the results of the given queries
      Since:
      3.2
    • intersect

      @Nonnull <T> CriteriaSelect<T> intersect(@Nonnull CriteriaSelect<? super T> left, @Nonnull CriteriaSelect<? super T> right)
      Create a query which is the intersection of the given queries.
      Type Parameters:
      T - the result type of the query
      Returns:
      a new criteria query which returns the intersection of the results of the given queries
      Since:
      3.2
    • intersectAll

      @Nonnull <T> CriteriaSelect<T> intersectAll(@Nonnull CriteriaSelect<? super T> left, @Nonnull CriteriaSelect<? super T> right)
      Create a query which is the intersection of the given queries, without elimination of duplicate results.
      Type Parameters:
      T - the result type of the query
      Returns:
      a new criteria query which returns the intersection of the results of the given queries
      Since:
      3.2
    • except

      @Nonnull <T> CriteriaSelect<T> except(@Nonnull CriteriaSelect<T> left, @Nonnull CriteriaSelect<?> right)
      Create a query by (setwise) subtraction of the second query from the first query.
      Type Parameters:
      T - the result type of the query
      Returns:
      a new criteria query which returns the result of subtracting the results of the second query from the results of the first query
      Since:
      3.2
    • exceptAll

      @Nonnull <T> CriteriaSelect<T> exceptAll(@Nonnull CriteriaSelect<T> left, @Nonnull CriteriaSelect<?> right)
      Create a query by (setwise) subtraction of the second query from the first query, without elimination of duplicate results.
      Type Parameters:
      T - the result type of the query
      Returns:
      a new criteria query which returns the result of subtracting the results of the second query from the results of the first query
      Since:
      3.2