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.

Predicates combine within the query root. A join widens the root, after which the WhereBuilder produces predicates that may reference any entity in the query; a path on an entity outside the query fails when the query is built.

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(PredicateBuilder<? extends 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. The predicate inherits the query root: a join widens the root, admitting predicates that reference any entity in the query.

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

      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(PredicateBuilder<? extends 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. The predicate inherits the query root: a join widens the root, admitting predicates that reference any entity in the query.

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

      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.