Package com.querydsl.jpa.hibernate
Class AbstractHibernateQuery<T,Q extends AbstractHibernateQuery<T,Q>>
- java.lang.Object
-
- com.querydsl.core.support.QueryBase<Q>
-
- com.querydsl.core.support.FetchableQueryBase<T,Q>
-
- com.querydsl.core.support.FetchableSubQueryBase<T,Q>
-
- com.querydsl.jpa.JPAQueryBase<T,Q>
-
- com.querydsl.jpa.hibernate.AbstractHibernateQuery<T,Q>
-
- Type Parameters:
T- result typeQ- 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>,java.io.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected @Nullable java.lang.Booleancacheableprotected @Nullable java.lang.StringcacheRegionprotected @Nullable java.lang.Stringcommentprotected intfetchSizeprotected @Nullable org.hibernate.FlushModeflushModeprotected java.util.Map<Path<?>,org.hibernate.LockMode>lockModesprotected @Nullable java.lang.BooleanreadOnlyprotected inttimeout-
Fields inherited from class com.querydsl.jpa.JPAQueryBase
queryMixin
-
Fields inherited from class com.querydsl.core.support.QueryBase
MDC_PARAMETERS, MDC_QUERY
-
-
Constructor Summary
Constructors Constructor Description AbstractHibernateQuery(SessionHolder session, JPQLTemplates patterns, QueryMetadata metadata)AbstractHibernateQuery(org.hibernate.Session session)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Qclone()Clone the state of this query to a new instanceprotected abstract Qclone(SessionHolder sessionHolder)Qclone(org.hibernate.Session session)Clone the state of this query to a new instance with the given SessionQclone(org.hibernate.StatelessSession session)Clone the state of this query to a new instance with the given StatelessSessionprotected voidclone(Q query)org.hibernate.query.QuerycreateQuery()Expose the original Hibernate query for the given projectionprotected JPQLSerializercreateSerializer()java.util.List<T>fetch()longfetchCount()TfetchOne()QueryResults<T>fetchResults()com.mysema.commons.lang.CloseableIterator<T>iterate()Return the query results as anIterator.protected voidlogQuery(java.lang.String queryString)protected voidreset()org.hibernate.ScrollableResultsscroll(org.hibernate.ScrollMode mode)Return the query results asScrollableResults.QsetCacheable(boolean cacheable)Enable caching of this query result set.QsetCacheRegion(java.lang.String cacheRegion)Set the name of the cache region.QsetComment(java.lang.String comment)Add a comment to the generated SQL.QsetFetchSize(int fetchSize)Set a fetchJoin size for the underlying JDBC query.QsetFlushMode(org.hibernate.FlushMode flushMode)Override the current session flush mode, just for this query.QsetLockMode(Path<?> path, org.hibernate.LockMode lockMode)Set the lock mode for the given path.QsetReadOnly(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.QsetTimeout(int timeout)Set a timeout for the underlying JDBC query.java.util.stream.Stream<T>stream()-
Methods inherited from class com.querydsl.jpa.JPAQueryBase
fetchJoin, from, from, from, getTemplates, innerJoin, innerJoin, innerJoin, innerJoin, innerJoin, innerJoin, join, join, join, join, join, join, leftJoin, leftJoin, leftJoin, leftJoin, leftJoin, leftJoin, on, on, rightJoin, rightJoin, rightJoin, rightJoin, rightJoin, rightJoin, serialize, serialize, toString
-
Methods inherited from class com.querydsl.core.support.FetchableSubQueryBase
accept, contains, contains, eq, eq, exists, getMetadata, getType, goe, goe, gt, gt, hashCode, in, in, isNotNull, isNull, loe, loe, lt, lt, ne, ne, notExists
-
Methods inherited from class com.querydsl.core.support.FetchableQueryBase
equals, fetchFirst, transform, uniqueResult
-
Methods inherited from class com.querydsl.core.support.QueryBase
distinct, groupBy, groupBy, having, having, limit, offset, orderBy, orderBy, restrict, set, where, where
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.querydsl.core.types.Expression
accept, getType
-
Methods inherited from interface com.querydsl.core.support.ExtendedSubQuery
contains, contains, eq, eq, exists, goe, goe, gt, gt, in, in, isNotNull, isNull, loe, loe, lt, lt, ne, ne, notExists
-
Methods inherited from interface com.querydsl.core.Fetchable
fetchFirst
-
Methods inherited from interface com.querydsl.core.FetchableQuery
transform
-
Methods inherited from interface com.querydsl.core.FilteredClause
where
-
Methods inherited from interface com.querydsl.core.SimpleQuery
distinct, limit, offset, orderBy, restrict, set
-
Methods inherited from interface com.querydsl.core.types.SubQueryExpression
getMetadata
-
-
-
-
Field Detail
-
cacheable
@Nullable protected @Nullable java.lang.Boolean cacheable
-
readOnly
@Nullable protected @Nullable java.lang.Boolean readOnly
-
cacheRegion
@Nullable protected @Nullable java.lang.String cacheRegion
-
comment
@Nullable protected @Nullable java.lang.String comment
-
fetchSize
protected int fetchSize
-
lockModes
protected final java.util.Map<Path<?>,org.hibernate.LockMode> lockModes
-
flushMode
@Nullable protected @Nullable org.hibernate.FlushMode flushMode
-
timeout
protected int timeout
-
-
Constructor Detail
-
AbstractHibernateQuery
public AbstractHibernateQuery(org.hibernate.Session session)
-
AbstractHibernateQuery
public AbstractHibernateQuery(SessionHolder session, JPQLTemplates patterns, QueryMetadata metadata)
-
-
Method Detail
-
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 anIterator. If the query contains multiple results pre row, the results are returned in an instance ofObject[].
Entities returned as results are initialized on demand. The first SQL query returns identifiers only.
-
stream
public java.util.stream.Stream<T> stream()
-
fetch
public java.util.List<T> fetch()
- Specified by:
fetchin interfaceFetchable<T>- Overrides:
fetchin classFetchableQueryBase<T,Q extends AbstractHibernateQuery<T,Q>>
-
fetchResults
public QueryResults<T> fetchResults()
-
logQuery
protected void logQuery(java.lang.String queryString)
-
reset
protected void reset()
- Specified by:
resetin classJPAQueryBase<T,Q extends AbstractHibernateQuery<T,Q>>
-
scroll
public org.hibernate.ScrollableResults scroll(org.hibernate.ScrollMode mode)
Return the query results asScrollableResults. The scrollability of the returned results depends upon JDBC driver support for scrollableResultSets.- 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(java.lang.String cacheRegion)
Set the name of the cache region.- Parameters:
cacheRegion- the name of a query cache region, ornullfor the default query cache
-
setComment
public Q setComment(java.lang.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:
createSerializerin classJPAQueryBase<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:
clonein classJPAQueryBase<T,Q extends AbstractHibernateQuery<T,Q>>- Returns:
- closed query
-
-