select. It is a slimmed-down version of Query, providing
only methods relevant to selection queries.
A SelectionQuery may be obtained from the org.
by calling:
QueryProducer#createSelectionQuery(String, Class), passing the
HQL as a string,
QueryProducer#createSelectionQuery(jakarta.persistence.criteria.CriteriaQuery) ,
passing a criteria
query object, or
QueryProducer#createNamedSelectionQuery(String, Class) passing
the name of a query defined using jakarta.persistence.NamedQuery
or jakarta.persistence.NamedNativeQuery .
A SelectionQuery controls how a query is executed, and allows arguments
to be bound to its parameters.
getResultList() or
getSingleResult().
setMaxResults(int) and setFirstResult(int)
control limits and pagination.
setParameter(String, Object) and
setParameter(int, Object) allow arguments to be bound to named
and ordinal parameters defined by the query.
A query may have explicit fetch joins, specified using the syntax
join fetch in HQL, or via jakarta.
in the criteria API. Additional fetch joins may be added by:
EntityGraph by calling
setEntityGraph(EntityGraph, GraphSemantic), or
Session#enableFetchProfile(String).
The special built-in fetch profile named
org.hibernate.defaultProfile adds
a fetch join for every eager
@ManyToOne or @OneToOne association belonging to an entity
returned by the query.
| Modifier and Type | Method and Description |
|---|---|
| public SelectionQuery | disableFetchProfile(String
the name of the fetch profile to be disabled profileName)Disable the |
| public SelectionQuery | enableFetchProfile(String
the name of the fetch profile to be enabled profileName)Enable the |
| public CacheMode | |
| public String | getCacheRegion()
Obtain the name of the second level query cache region in which query
results will be stored (if they are cached, see the discussion on
|
| public CacheRetrieveMode | |
| public CacheStoreMode | |
| public Integer | Returns: The timeout in secondsObtain the JDBC fetch size hint in effect for this query. |
| public int | |
| public LockMode | |
| public LockModeType | |
| public LockOptions | |
| public int | |
| public default List | Returns: the results as a listExecute the query and return the query results as a |
| public default Stream | Returns: The results as aStreamExecute the query and return the query results as a |
| public R | Returns: the single result, only if there is exactly oneExecute the query and return the single result of the query, throwing an exception if the query returns no results. |
| public R | Returns: the single result ornull if there is no result to returnExecute the query and return the single result of the query,
or |
| public boolean | |
| public boolean | |
| public boolean | Returns: true if the entities and proxies loaded by the query
will be put in read-only mode; false otherwise
(they will be modifiable)Should entities and proxies loaded by this Query be put in read-only mode? |
| public List | |
| public ScrollableResults | |
| public ScrollableResults | |
| public @Remove SelectionQuery | setAliasSpecificLockMode(String alias, LockMode lockMode)
Deprecated
since 6.2. use
Specify a setLockMode(String, LockMode)
LockMode to apply to a specific alias defined in the query
|
| public SelectionQuery | |
| public SelectionQuery | |
| public SelectionQuery | setCacheRegion(String cacheRegion)
Set the name of the cache region where query results should be cached
(assuming |
| public SelectionQuery | |
| public SelectionQuery | |
| public SelectionQuery | setComment(String comment)
Redeclares org. |
| public SelectionQuery | |
| public SelectionQuery | Returns: this, for method chainingthe fetch size hint fetchSize)Sets a JDBC fetch size hint for the query. |
| public SelectionQuery | |
| public SelectionQuery | setFlushMode(FlushModeType flushMode)
Redeclares org. FlushMode in to use for this query.
|
| public SelectionQuery | |
| public SelectionQuery | setHibernateFlushMode(FlushMode flushMode)
Redeclares org. FlushMode in effect for this query.
|
| public SelectionQuery | |
| public SelectionQuery | setHint(String hintName, Object value)
Redeclares org. |
| public SelectionQuery | |
| public SelectionQuery | setLockMode(String alias, LockMode lockMode)
Specify a |
| public SelectionQuery | |
| public SelectionQuery | |
| public SelectionQuery | |
| public SelectionQuery | |
| public SelectionQuery | setParameter(String name, Object value)
Redeclares org. |
| public <P> SelectionQuery | setParameter(String name, P value, Class<P> type)
Redeclares org. Class reference to attempt to infer the BindableType.
|
| public <P> SelectionQuery | setParameter(String name, P value, BindableType<P> type)
Redeclares org. BindableType.
|
| public SelectionQuery | setParameter(String name, Instant value, TemporalType temporalType)
Redeclares org. Instant to the named query parameter using just the
portion indicated by the given TemporalType.
|
| public SelectionQuery | setParameter(String name, Calendar value, TemporalType temporalType)
Redeclares org. |
| public SelectionQuery | setParameter(String name, Date value, TemporalType temporalType)
Redeclares org. |
| public SelectionQuery | setParameter(int position, Object value)
Redeclares org. |
| public <P> SelectionQuery | setParameter(int position, P value, Class<P> type)
Redeclares org. Class reference to attempt to infer the BindableType.
|
| public <P> SelectionQuery | setParameter(int position, P value, BindableType<P> type)
Redeclares org. BindableType.
|
| public SelectionQuery | setParameter(int position, Instant value, TemporalType temporalType)
Redeclares org. Instant to an ordinal query parameter using just the
portion indicated by the given TemporalType.
|
| public SelectionQuery | setParameter(int position, Date value, TemporalType temporalType)
Redeclares org. |
| public SelectionQuery | setParameter(int position, Calendar value, TemporalType temporalType)
Redeclares org. |
| public <T> SelectionQuery | setParameter(QueryParameter<T>
the query parameter memento parameter, T the argument, which might be null value)Redeclares org. QueryParameter.
|
| public <P> SelectionQuery | setParameter(QueryParameter<P>
the query parameter memento parameter, P the argument, which might be null value, Class<P> a type)BindableType representing the type of the parameterRedeclares org. QueryParameter, using the given Class reference to attempt
to infer the BindableType to use.
|
| public <P> SelectionQuery | setParameter(QueryParameter<P>
the query parameter memento parameter, P the argument, which might be null val, BindableType<P> a type)BindableType representing the type of the parameterRedeclares org. QueryParameter, using the given BindableType.
|
| public <T> SelectionQuery | setParameter(Parameter<T> param, T value)
Redeclares org. |
| public SelectionQuery | setParameter(Parameter<Calendar> param, Calendar value, TemporalType temporalType)
Redeclares org. |
| public SelectionQuery | setParameter(Parameter<Date> param, Date value, TemporalType temporalType)
Redeclares org. |
| public SelectionQuery | setParameterList(String name, Collection<E> values)
Redeclares org. |
| public <P> SelectionQuery | setParameterList(String name, Collection<? extends P> values, Class<P> javaType)
Redeclares org. Class reference to attempt to infer the BindableType
If unable to infer an appropriate BindableType, fall back to
setParameterList(String, Collection).
|
| public <P> SelectionQuery | setParameterList(String name, Collection<? extends P> values, BindableType<P> type)
Redeclares org. BindableType.
|
| public SelectionQuery | setParameterList(String name, Object[] values)
Redeclares org. |
| public <P> SelectionQuery | setParameterList(String name, P[] values, Class<P> javaType)
Redeclares org. BindableType
to use.
|
| public <P> SelectionQuery | setParameterList(String name, P[] values, BindableType<P> type)
Redeclares org. BindableType.
|
| public SelectionQuery | setParameterList(int position, Collection<E> values)
Redeclares org. |
| public <P> SelectionQuery | setParameterList(int position, Collection<? extends P> values, Class<P> javaType)
Redeclares org. Class reference to attempt to infer the BindableType.
|
| public <P> SelectionQuery | setParameterList(int position, Collection<? extends P> values, BindableType<P> type)
Redeclares org. BindableType.
|
| public SelectionQuery | setParameterList(int position, Object[] values)
Redeclares org. |
| public <P> SelectionQuery | setParameterList(int position, P[] values, Class<P> javaType)
Redeclares org. Class reference to attempt to infer the BindableType.
|
| public <P> SelectionQuery | setParameterList(int position, P[] values, BindableType<P> type)
Redeclares org. BindableType.
|
| public <P> SelectionQuery | setParameterList(QueryParameter<P>
the parameter memento parameter, Collection<? extends P> a collection of arguments values)Redeclares org. QueryParameter.
|
| public <P> SelectionQuery | setParameterList(QueryParameter<P> parameter, Collection<? extends P> values, Class<P> javaType)
Redeclares org. QueryParameter using the given Class reference
to attempt to infer the BindableType to use.
|
| public <P> SelectionQuery | setParameterList(QueryParameter<P> parameter, Collection<? extends P> values, BindableType<P> type)
Redeclares org. QueryParameter, using the given BindableType.
|
| public <P> SelectionQuery | setParameterList(QueryParameter<P>
the parameter memento parameter, P[] a collection of arguments values)Redeclares org. QueryParameter.
|
| public <P> SelectionQuery | setParameterList(QueryParameter<P> parameter, P[] values, Class<P> javaType)
Redeclares org. QueryParameter using the given Class reference
to attempt to infer the BindableType to use.
|
| public <P> SelectionQuery | setParameterList(QueryParameter<P> parameter, P[] values, BindableType<P> type)
Redeclares org. QueryParameter, using the given the BindableType.
|
| public SelectionQuery | setProperties(Object
any JavaBean or POJO bean)Redeclares org. |
| public SelectionQuery | setProperties(Map<K, V>
a bean)Map of names to argumentsRedeclares org. Map to named parameters of the
query, matching key names with parameter names and mapping value types
to Hibernate types using heuristics.
|
| public SelectionQuery | |
| public SelectionQuery | Returns: this, for method chainingtrue indicates that entities and proxies
loaded by the query are to be put in read-only mode;
false indicates that entities and proxies
loaded by the query will be put in modifiable modeSet the read-only/modifiable mode for entities and proxies loaded
by this |
| public SelectionQuery | setTimeout(int
the timeout in seconds timeout)Redeclares org. |
| public default Stream | |
| public R | Returns: the single result ornullExecute the query and return the single result of the query,
or |
| public Optional | Returns: the single result as anOptionalExecute the query and return the single result of the query,
as an |