T
- result typeQ
- concrete subtypepublic abstract class AbstractHibernateQuery<T,Q extends AbstractHibernateQuery<T,Q>> extends JPAQueryBase<T,Q>
Modifier and Type | Field and Description |
---|---|
protected @Nullable java.lang.Boolean |
cacheable |
protected @Nullable java.lang.String |
cacheRegion |
protected @Nullable java.lang.String |
comment |
protected int |
fetchSize |
protected @Nullable org.hibernate.FlushMode |
flushMode |
protected java.util.Map<Path<?>,org.hibernate.LockMode> |
lockModes |
protected @Nullable java.lang.Boolean |
readOnly |
protected int |
timeout |
queryMixin
MDC_PARAMETERS, MDC_QUERY
Constructor and Description |
---|
AbstractHibernateQuery(org.hibernate.Session session) |
AbstractHibernateQuery(SessionHolder session,
JPQLTemplates patterns,
QueryMetadata metadata) |
Modifier and Type | Method and Description |
---|---|
Q |
clone()
Clone the state of this query to a new instance
|
protected void |
clone(Q query) |
Q |
clone(org.hibernate.Session session)
Clone the state of this query to a new instance with the given Session
|
protected abstract Q |
clone(SessionHolder sessionHolder) |
Q |
clone(org.hibernate.StatelessSession session)
Clone the state of this query to a new instance with the given StatelessSession
|
org.hibernate.query.Query |
createQuery()
Expose the original Hibernate query for the given projection
|
protected JPQLSerializer |
createSerializer() |
java.util.List<T> |
fetch()
Get the projection as a typed List
|
long |
fetchCount()
Get the count of matched elements
Note: not all QueryDSL modules might optimize fetchCount using a count query.
|
T |
fetchOne()
Get the projection as a unique result or null if no result is found
|
QueryResults<T> |
fetchResults()
Get the projection in
QueryResults form. |
com.mysema.commons.lang.CloseableIterator<T> |
iterate()
Return the query results as an
Iterator . |
protected void |
logQuery(java.lang.String queryString) |
protected void |
reset() |
org.hibernate.ScrollableResults |
scroll(org.hibernate.ScrollMode mode)
Return the query results as
ScrollableResults . |
Q |
setCacheable(boolean cacheable)
Enable caching of this query result set.
|
Q |
setCacheRegion(java.lang.String cacheRegion)
Set the name of the cache region.
|
Q |
setComment(java.lang.String comment)
Add a comment to the generated SQL.
|
Q |
setFetchSize(int fetchSize)
Set a fetchJoin size for the underlying JDBC query.
|
Q |
setFlushMode(org.hibernate.FlushMode flushMode)
Override the current session flush mode, just for this query.
|
Q |
setLockMode(Path<?> path,
org.hibernate.LockMode lockMode)
Set the lock mode for the given path.
|
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.
|
Q |
setTimeout(int timeout)
Set a timeout for the underlying JDBC query.
|
java.util.stream.Stream<T> |
stream()
Get the projection as a typed closeable Stream.
|
fetchAll, 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
accept, contains, contains, eq, eq, exists, getMetadata, getType, goe, goe, gt, gt, hashCode, in, in, isNotNull, isNull, loe, loe, lt, lt, ne, ne, notExists
equals, fetchFirst, transform, uniqueResult
distinct, groupBy, groupBy, having, having, limit, offset, orderBy, orderBy, restrict, set, where, where
finalize, getClass, notify, notifyAll, wait, wait, wait
transform
fetchFirst
distinct, limit, offset, orderBy, restrict, set
where
contains, contains, eq, eq, exists, goe, goe, gt, gt, in, in, isNotNull, isNull, loe, loe, lt, lt, ne, ne, notExists
getMetadata
accept, getType
@Nullable protected @Nullable java.lang.Boolean cacheable
@Nullable protected @Nullable java.lang.Boolean readOnly
@Nullable protected @Nullable java.lang.String cacheRegion
@Nullable protected @Nullable java.lang.String comment
protected int fetchSize
protected final java.util.Map<Path<?>,org.hibernate.LockMode> lockModes
@Nullable protected @Nullable org.hibernate.FlushMode flushMode
protected int timeout
public AbstractHibernateQuery(org.hibernate.Session session)
public AbstractHibernateQuery(SessionHolder session, JPQLTemplates patterns, QueryMetadata metadata)
public long fetchCount()
Fetchable
fetch().size()
.public org.hibernate.query.Query createQuery()
public com.mysema.commons.lang.CloseableIterator<T> iterate()
Iterator
. If the query
contains multiple results pre row, the results are returned in
an instance of Object[]
.public java.util.stream.Stream<T> stream()
Fetchable
public java.util.List<T> fetch()
Fetchable
fetch
in interface Fetchable<T>
fetch
in class FetchableQueryBase<T,Q extends AbstractHibernateQuery<T,Q>>
public QueryResults<T> fetchResults()
Fetchable
QueryResults
form.
Make sure to use Fetchable.fetch()
instead if you do not rely on the QueryResults.getOffset()
or
QueryResults.getLimit()
, because it will be more performant. Also, count queries cannot be
properly generated for all dialects. For example: in JPA count queries can't be generated for queries
that have multiple group by expressions or a having clause.
Get the projection in QueryResults
form.
Use Fetchable.fetch()
instead if you do not need the total count of rows in the query result.Fetchable.fetch()
protected void logQuery(java.lang.String queryString)
protected void reset()
reset
in class JPAQueryBase<T,Q extends AbstractHibernateQuery<T,Q>>
public org.hibernate.ScrollableResults scroll(org.hibernate.ScrollMode mode)
ScrollableResults
. The
scrollability of the returned results depends upon JDBC driver
support for scrollable ResultSet
s.mode
- scroll modepublic Q setCacheable(boolean cacheable)
cacheable
- Should the query results be cacheable?public Q setCacheRegion(java.lang.String cacheRegion)
cacheRegion
- the name of a query cache region, or null
for the default query cachepublic Q setComment(java.lang.String comment)
comment
- commentpublic Q setFetchSize(int fetchSize)
fetchSize
- the fetchJoin sizepublic Q setLockMode(Path<?> path, org.hibernate.LockMode lockMode)
public Q setFlushMode(org.hibernate.FlushMode flushMode)
public Q setReadOnly(boolean readOnly)
public Q setTimeout(int timeout)
timeout
- the timeout in secondspublic T fetchOne() throws NonUniqueResultException
Fetchable
NonUniqueResultException
- if there is more than one matching resultprotected JPQLSerializer createSerializer()
createSerializer
in class JPAQueryBase<T,Q extends AbstractHibernateQuery<T,Q>>
protected void clone(Q query)
protected abstract Q clone(SessionHolder sessionHolder)
public Q clone(org.hibernate.Session session)
session
- sessionpublic Q clone(org.hibernate.StatelessSession session)
session
- sessionpublic Q clone()
clone
in class JPAQueryBase<T,Q extends AbstractHibernateQuery<T,Q>>
Copyright © 2007–2021 Querydsl. All rights reserved.