Class QueryType<X,C extends jakarta.persistence.criteria.CommonAbstractCriteria,C2 extends C,Q extends jakarta.persistence.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 jakarta.persistence.criteria.CommonAbstractCriteria,C2 extends C,Q extends jakarta.persistence.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 Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Class<X>
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    QueryType(Class<X> type)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract C2
    createCriteriaQuery(jakarta.persistence.criteria.CriteriaBuilder builder)
    Create a new Criteria API query object of the appropriate type.
    abstract Q
    createQuery(jakarta.persistence.EntityManager entityManager, C2 query)
    Create a JPA query object of the appropriate type.
    Get the query result/target type associated with this instance.
    abstract void
    where(C query, jakarta.persistence.criteria.Expression<Boolean> restriction)
    Configure the restriction associated with the given query.
    abstract void
    where(C query, jakarta.persistence.criteria.Predicate restriction)
    Configure the restriction associated with the given query.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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(jakarta.persistence.criteria.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(jakarta.persistence.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, jakarta.persistence.criteria.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, jakarta.persistence.criteria.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