public static interface Mutiny.Query<R>
Query
interface, allowing reactive
execution of HQL and JPQL queries.
The semantics of operations on this interface are identical to the
semantics of the similarly-named operations of Query
, except
that the operations are performed asynchronously, returning a
Uni
without blocking the calling thread.
Note that TemporalType
is not supported
as an argument for parameter bindings, and so parameters of type
Date
or Calendar
should not be
used. Instead, datetime types from java.time
should be used
as parameters.
Query
Modifier and Type | Method and Description |
---|---|
io.smallrye.mutiny.Uni<Integer> |
executeUpdate()
Asynchronously execute this delete, update, or insert query,
returning the updated row count.
|
org.hibernate.CacheMode |
getCacheMode()
Obtain the
CacheMode in effect for this query. |
String |
getCacheRegion() |
int |
getFirstResult() |
org.hibernate.FlushMode |
getFlushMode()
Obtain the
FlushMode in effect for this query. |
int |
getMaxResults() |
io.smallrye.mutiny.Uni<List<R>> |
getResultList()
Asynchronously execute this query, returning the query results
as a
List , via a Uni . |
io.smallrye.mutiny.Uni<R> |
getSingleResult()
Asynchronously execute this query, returning a single row that
matches the query, throwing an exception if the query returns
zero rows or more than one matching row.
|
io.smallrye.mutiny.Uni<R> |
getSingleResultOrNull()
Asynchronously execute this query, returning a single row that
matches the query, or
null if the query returns no results,
throwing an exception if the query returns more than one matching
row. |
boolean |
isCacheable() |
boolean |
isReadOnly() |
Mutiny.Query<R> |
setCacheable(boolean cacheable)
Enable or disable caching of this query result set in the
second-level query cache.
|
Mutiny.Query<R> |
setCacheMode(org.hibernate.CacheMode cacheMode)
Set the current
CacheMode in effect while this query
is being executed. |
Mutiny.Query<R> |
setCacheRegion(String cacheRegion)
Set the name of the cache region in which to store this
query result set if
caching is enabled . |
Mutiny.Query<R> |
setComment(String comment)
Set the comment for this query.
|
Mutiny.Query<R> |
setFirstResult(int firstResult)
Set the position of the first result that may be returned by
this query when executed, where the results are numbered from
0.
|
Mutiny.Query<R> |
setFlushMode(org.hibernate.FlushMode flushMode)
Set the current
FlushMode in effect while this query is
being executed. |
Mutiny.Query<R> |
setLockMode(org.hibernate.LockMode lockMode)
Set the
LockMode to use for the whole query. |
Mutiny.Query<R> |
setLockMode(String alias,
org.hibernate.LockMode lockMode)
Set the
LockMode to use for specified alias (as defined in
the query's from clause). |
Mutiny.Query<R> |
setMaxResults(int maxResults)
Set the maximum number of results that may be returned by this
query when executed.
|
Mutiny.Query<R> |
setParameter(int parameter,
Object argument)
Set the value of an ordinal parameter.
|
<T> Mutiny.Query<R> |
setParameter(Parameter<T> parameter,
T argument)
Set the value of a typed parameter.
|
Mutiny.Query<R> |
setParameter(String parameter,
Object argument)
Set the value of a named parameter.
|
Mutiny.Query<R> |
setReadOnly(boolean readOnly)
Set the read-only/modifiable mode for entities and proxies
loaded by this Query.
|
Mutiny.Query<R> setParameter(int parameter, Object argument)
?1
, ?2
, etc.parameter
- an integer identifying the ordinal parameterargument
- the argument to setMutiny.Query<R> setParameter(String parameter, Object argument)
:name
.parameter
- the name of the parameterargument
- the argument to set<T> Mutiny.Query<R> setParameter(Parameter<T> parameter, T argument)
CriteriaBuilder
, which may
itself be obtained by calling
Mutiny.SessionFactory.getCriteriaBuilder()
.parameter
- the parameterargument
- the argument to setCriteriaBuilder.parameter(Class)
Mutiny.Query<R> setMaxResults(int maxResults)
Mutiny.Query<R> setFirstResult(int firstResult)
int getMaxResults()
Integer.MAX_VALUE
if not setint getFirstResult()
io.smallrye.mutiny.Uni<R> getSingleResult()
Object[]
.NoResultException
- if there is no resultNonUniqueResultException
- if there are multiple resultsQuery.getSingleResult()
io.smallrye.mutiny.Uni<R> getSingleResultOrNull()
null
if the query returns no results,
throwing an exception if the query returns more than one matching
row. If the query has multiple results per row, the results are
returned in an instance of Object[]
.null
NonUniqueResultException
- if there are multiple resultsgetSingleResult()
io.smallrye.mutiny.Uni<List<R>> getResultList()
List
, via a Uni
. If the query has multiple
results per row, the results are returned in an instance of
Object[]
. If the query has multiple results per row,
the results are returned in an instance of Object[]
.List
Query.getResultList()
io.smallrye.mutiny.Uni<Integer> executeUpdate()
Query.executeUpdate()
Mutiny.Query<R> setReadOnly(boolean readOnly)
boolean isReadOnly()
Mutiny.Session.isDefaultReadOnly()
Mutiny.Query<R> setComment(String comment)
comment
- The human-readable commentMutiny.Query<R> setCacheable(boolean cacheable)
cacheable
- true
if this query is cacheableboolean isCacheable()
true
if this query is cacheablesetCacheable(boolean)
Mutiny.Query<R> setCacheRegion(String cacheRegion)
caching is enabled
.cacheRegion
- the name of the cache regionString getCacheRegion()
setCacheRegion(String)
Mutiny.Query<R> setCacheMode(org.hibernate.CacheMode cacheMode)
CacheMode
in effect while this query
is being executed.org.hibernate.CacheMode getCacheMode()
CacheMode
in effect for this query. By default,
the query inherits the CacheMode
of the Mutiny.Session
from which is originates.Mutiny.Session.getCacheMode()
Mutiny.Query<R> setFlushMode(org.hibernate.FlushMode flushMode)
FlushMode
in effect while this query is
being executed.org.hibernate.FlushMode getFlushMode()
FlushMode
in effect for this query. By default,
the query inherits the FlushMode
of the Mutiny.Session
from which is originates.Mutiny.Session.getFlushMode()
Mutiny.Query<R> setLockMode(org.hibernate.LockMode lockMode)
LockMode
to use for the whole query.Mutiny.Query<R> setLockMode(String alias, org.hibernate.LockMode lockMode)
LockMode
to use for specified alias (as defined in
the query's from
clause).alias
- the from clause aliaslockMode
- the requested LockMode
Query.setLockMode(String,LockMode)
Copyright © 2020-2022 Red Hat, Inc. All Rights Reserved.