Class AbstractHibernateQuery<T,Q extends AbstractHibernateQuery<T,Q>>

Type Parameters:
T - result type
Q - concrete subtype
All Implemented Interfaces:
Fetchable<T>, FetchableQuery<T,JPQLQuery<T>>, FilteredClause<JPQLQuery<T>>, Query<JPQLQuery<T>>, SimpleQuery<JPQLQuery<T>>, ExtendedSubQuery<T>, Expression<T>, SubQueryExpression<T>, JPQLQuery<T>, Serializable
Direct Known Subclasses:
HibernateQuery

public abstract class AbstractHibernateQuery<T,Q extends AbstractHibernateQuery<T,Q>> extends JPAQueryBase<T,Q>
Abstract base class for Hibernate API based implementations of the JPQL interface
Author:
tiwe
See Also:
  • Field Details

    • cacheable

      @Nullable protected @Nullable Boolean cacheable
    • readOnly

      @Nullable protected @Nullable Boolean readOnly
    • cacheRegion

      @Nullable protected @Nullable String cacheRegion
    • comment

      @Nullable protected @Nullable String comment
    • fetchSize

      protected int fetchSize
    • lockModes

      protected final Map<Path<?>,org.hibernate.LockMode> lockModes
    • flushMode

      @Nullable protected @Nullable org.hibernate.FlushMode flushMode
    • timeout

      protected int timeout
  • Constructor Details

    • AbstractHibernateQuery

      public AbstractHibernateQuery(org.hibernate.Session session)
    • AbstractHibernateQuery

      public AbstractHibernateQuery(SessionHolder session, JPQLTemplates patterns, QueryMetadata metadata)
  • Method Details

    • fetchCount

      public long fetchCount()
    • createQuery

      public org.hibernate.query.Query createQuery()
      Expose the original Hibernate query for the given projection
      Returns:
      query
    • iterate

      public com.mysema.commons.lang.CloseableIterator<T> iterate()
      Return the query results as an Iterator. If the query contains multiple results pre row, the results are returned in an instance of Object[].

      Entities returned as results are initialized on demand. The first SQL query returns identifiers only.
    • stream

      public Stream<T> stream()
    • fetch

      public List<T> fetch()
      Specified by:
      fetch in interface Fetchable<T>
      Overrides:
      fetch in class FetchableQueryBase<T,Q extends AbstractHibernateQuery<T,Q>>
    • fetchResults

      public QueryResults<T> fetchResults()
    • logQuery

      protected void logQuery(String queryString)
    • reset

      protected void reset()
      Specified by:
      reset in class JPAQueryBase<T,Q extends AbstractHibernateQuery<T,Q>>
    • scroll

      public org.hibernate.ScrollableResults scroll(org.hibernate.ScrollMode mode)
      Return the query results as ScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollable ResultSets.
      Parameters:
      mode - scroll mode
      Returns:
      scrollable results
    • setCacheable

      public Q setCacheable(boolean cacheable)
      Enable caching of this query result set.
      Parameters:
      cacheable - Should the query results be cacheable?
    • setCacheRegion

      public Q setCacheRegion(String cacheRegion)
      Set the name of the cache region.
      Parameters:
      cacheRegion - the name of a query cache region, or null for the default query cache
    • setComment

      public Q setComment(String comment)
      Add a comment to the generated SQL.
      Parameters:
      comment - comment
      Returns:
      the current object
    • setFetchSize

      public Q setFetchSize(int fetchSize)
      Set a fetchJoin size for the underlying JDBC query.
      Parameters:
      fetchSize - the fetchJoin size
      Returns:
      the current object
    • setLockMode

      public Q setLockMode(Path<?> path, org.hibernate.LockMode lockMode)
      Set the lock mode for the given path.
      Returns:
      the current object
    • setFlushMode

      public Q setFlushMode(org.hibernate.FlushMode flushMode)
      Override the current session flush mode, just for this query.
      Returns:
      the current object
    • setReadOnly

      public Q setReadOnly(boolean readOnly)
      Entities retrieved by this query will be loaded in a read-only mode where Hibernate will never dirty-check them or make changes persistent.
      Returns:
      the current object
    • setTimeout

      public Q setTimeout(int timeout)
      Set a timeout for the underlying JDBC query.
      Parameters:
      timeout - the timeout in seconds
      Returns:
      the current object
    • fetchOne

      public T fetchOne() throws NonUniqueResultException
      Throws:
      NonUniqueResultException
    • createSerializer

      protected JPQLSerializer createSerializer()
      Specified by:
      createSerializer in class JPAQueryBase<T,Q extends AbstractHibernateQuery<T,Q>>
    • clone

      protected void clone(Q query)
    • clone

      protected abstract Q clone(SessionHolder sessionHolder)
    • clone

      public Q clone(org.hibernate.Session session)
      Clone the state of this query to a new instance with the given Session
      Parameters:
      session - session
      Returns:
      cloned query
    • clone

      public Q clone(org.hibernate.StatelessSession session)
      Clone the state of this query to a new instance with the given StatelessSession
      Parameters:
      session - session
      Returns:
      cloned query
    • clone

      public Q clone()
      Clone the state of this query to a new instance
      Specified by:
      clone in class JPAQueryBase<T,Q extends AbstractHibernateQuery<T,Q>>
      Returns:
      closed query