Class QueryType<X,C extends CommonAbstractCriteria,C2 extends C,Q extends Query>

java.lang.Object
org.dellroad.querystream.jpa.querytype.QueryType<X,C,C2,Q>
Type Parameters:
X - query result/target type
C - configured criteria API query type
C2 - final criteria API query type
Q - final JPA query type
Direct Known Subclasses:
DeleteType, SearchType, UpdateType

public abstract class QueryType<X,C extends CommonAbstractCriteria,C2 extends C,Q extends Query> extends Object
Instances represent one of the three types of JPA criteria API queries: search, update, or delete, for a specific target type.
  • Field Details

    • type

      protected final Class<X> type
  • Constructor Details

    • QueryType

      protected QueryType(Class<X> type)
      Constructor.
      Parameters:
      type - query result/target type
      Throws:
      IllegalArgumentException - if type is null
  • Method Details

    • getType

      public Class<X> getType()
      Get the query result/target type associated with this instance.
      Returns:
      query result/target type
    • createCriteriaQuery

      public abstract C2 createCriteriaQuery(CriteriaBuilder builder)
      Create a new Criteria API query object of the appropriate type.
      Parameters:
      builder - criteria builder
      Returns:
      new criteria query object
      Throws:
      IllegalArgumentException - if builder is null
    • createQuery

      public abstract Q createQuery(EntityManager entityManager, C2 query)
      Create a JPA query object of the appropriate type.
      Parameters:
      entityManager - JPA entity manager
      query - criteria query object
      Returns:
      new executable JPA query object
      Throws:
      IllegalArgumentException - if entityManager or query is null
    • where

      public abstract void where(C query, Expression<Boolean> restriction)
      Configure the restriction associated with the given query.
      Parameters:
      query - criteria query object
      restriction - query restriction
      Throws:
      IllegalArgumentException - if query or expression is null
    • where

      public abstract void where(C query, Predicate restriction)
      Configure the restriction associated with the given query.
      Parameters:
      query - criteria query object
      restriction - query restriction
      Throws:
      IllegalArgumentException - if query or expression is null