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<java.lang.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. |
int |
getFirstResult() |
org.hibernate.FlushMode |
getFlushMode()
Obtain the
FlushMode in effect for this query. |
int |
getMaxResults() |
io.smallrye.mutiny.Uni<java.util.List<R>> |
getResultList()
Asynchronously execute this query, returning the query results
as a
List , via a Uni . |
default io.smallrye.mutiny.Multi<R> |
getResults()
Asynchronously execute this query, returning the query results
as a
Multi . |
io.smallrye.mutiny.Uni<R> |
getSingleResult()
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 |
isReadOnly() |
Mutiny.Query<R> |
setCacheMode(org.hibernate.CacheMode cacheMode)
Set the current
CacheMode in effect while this query
is being executed. |
Mutiny.Query<R> |
setComment(java.lang.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(java.lang.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 position,
java.lang.Object value)
Set the value of a positional parameter.
|
<T> Mutiny.Query<R> |
setParameter(javax.persistence.Parameter<T> name,
T value)
Set the value of a typed parameter.
|
Mutiny.Query<R> |
setParameter(java.lang.String name,
java.lang.Object value)
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 position, java.lang.Object value)
?1
, ?2
, etc.Mutiny.Query<R> setParameter(java.lang.String name, java.lang.Object value)
:name
.<T> Mutiny.Query<R> setParameter(javax.persistence.Parameter<T> name, T value)
CriteriaBuilder
, which may
itself be obtained by calling
Mutiny.SessionFactory.getCriteriaBuilder()
.CriteriaBuilder.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()
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
Query.getSingleResult()
io.smallrye.mutiny.Uni<java.util.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()
default io.smallrye.mutiny.Multi<R> getResults()
Multi
. If the query has multiple results per row,
the results are returned in an instance of Object[]
.
For now, this operation does no more than simply repackage the
result of getResultList()
as a Multi
for
convenience.
Multi
io.smallrye.mutiny.Uni<java.lang.Integer> executeUpdate()
Query.executeUpdate()
Mutiny.Query<R> setReadOnly(boolean readOnly)
boolean isReadOnly()
Mutiny.Session.isDefaultReadOnly()
Mutiny.Query<R> setComment(java.lang.String comment)
comment
- The human-readable commentMutiny.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(java.lang.String alias, org.hibernate.LockMode lockMode)
LockMode
to use for specified alias (as defined in
the query's from
clause).Query.setLockMode(String,LockMode)