Module storm.java

Interface PredicateBuilder<T extends Data,R,ID>

Type Parameters:
T - the type of the table being queried.
R - the type of the result.
ID - the type of the primary key.

public interface PredicateBuilder<T extends Data,R,ID>
PredicateBuilder relies on preview features of the Java platform:
  • PredicateBuilder refers to one or more preview APIs: StringTemplate.
Programs can only use PredicateBuilder when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Represents a composable predicate for the WHERE clause of a query, supporting AND and OR composition.

PredicateBuilder instances are returned by the methods on WhereBuilder and can be combined using and(PredicateBuilder) and or(PredicateBuilder) to build compound conditions. Each combinator returns a new PredicateBuilder that represents the combined expression.

Methods named and/or are type-safe and restrict predicates to the root table's entity graph. Methods named andAny/orAny accept predicates from any table, including manually added joins.

Example


 List<User> users = userRepository
         .select()
         .where(predicate -> predicate
             .where(User_.active, EQUALS, true)
             .and(predicate.where(User_.email, IS_NOT_NULL))
             .or(predicate.where(User_.role, EQUALS, "admin")))
         .getResultList();
 
See Also:
  • Method Details

    • and

      PredicateBuilder<T,R,ID> and(@Nonnull PredicateBuilder<T,?,?> predicate)
      Adds a predicate to the WHERE clause using an AND condition.

      This method combines the specified predicate with existing predicates using an AND operation, ensuring that all added conditions must be true.

      Parameters:
      predicate - the predicate to add.
      Returns:
      the predicate builder.
    • andAny

      <TX extends Data, RX, IDX> PredicateBuilder<TX,RX,IDX> andAny(@Nonnull PredicateBuilder<TX,RX,IDX> predicate)
      Adds a predicate to the WHERE clause using an AND condition.

      This method combines the specified predicate with existing predicates using an AND operation, ensuring that all added conditions must be true.

      Parameters:
      predicate - the predicate to add.
      Returns:
      the predicate builder.
    • and

      PredicateBuilder<T,R,ID> and(@Nonnull StringTemplatePREVIEW template)
      Adds a predicate to the WHERE clause using an AND condition.

      This method combines the specified predicate with existing predicates using an AND operation, ensuring that all added conditions must be true.

      Parameters:
      template - the template string representing the predicate to add.
      Returns:
      the predicate builder.
    • or

      PredicateBuilder<T,R,ID> or(@Nonnull PredicateBuilder<T,?,?> predicate)
      Adds a predicate to the WHERE clause using an OR condition.

      This method combines the specified predicate with existing predicates using an OR operation, allowing any of the added conditions to be true.

      Parameters:
      predicate - the predicate to add.
      Returns:
      the predicate builder.
    • orAny

      <TX extends Data, RX, IDX> PredicateBuilder<TX,RX,IDX> orAny(@Nonnull PredicateBuilder<TX,RX,IDX> predicate)
      Adds a predicate to the WHERE clause using an OR condition.

      This method combines the specified predicate with existing predicates using an OR operation, allowing any of the added conditions to be true.

      Parameters:
      predicate - the predicate to add.
      Returns:
      the predicate builder.
    • or

      PredicateBuilder<T,R,ID> or(@Nonnull StringTemplatePREVIEW template)
      Adds a predicate to the WHERE clause using an OR condition.

      This method combines the specified predicate with existing predicates using an OR operation, ensuring that all added conditions must be true.

      Parameters:
      template - the template string representing the predicate to add.
      Returns:
      the predicate builder.