Object for untyped queries
The subtype NativeQuery represents a query written in native SQL.
This type simply mixes the TypedQuery interface defined by JPA with
SelectionQuery and MutationQuery. Unfortunately, JPA does
not distinguish between selection queries and
mutation queries, so we lose that distinction here.
However, every Query may logically be classified as one or the other.
A Query may be obtained from the org. by
calling:
QueryProducer#createQuery(String, Class), passing the HQL as a
string,
QueryProducer#createQuery(jakarta.persistence.criteria.CriteriaQuery) ,
passing a criteria
object, or
QueryProducer#createNamedQuery(String, Class) passing the name
of a query defined using jakarta.persistence.NamedQuery or
jakarta.persistence.NamedNativeQuery .
A Query 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.
Note that this interface offers no real advantages over SelectionQuery
except for compatibility with the JPA-defined TypedQuery interface.
QueryProducer
| Modifier and Type | Method and Description |
|---|---|
| public Query | addQueryHint(String
The database specific query hint to add. hint)Add a database query hint to the SQL query. |
| public default Query | |
| public Query | applyGraph(RootGraph<J>
The graph to apply. graph, GraphSemantic The semantic to use when applying the graph semantic)Apply the given graph using the given semantic |
| public default Query | |
| public Query | disableFetchProfile(String
the name of the fetch profile to be disabled profileName)Redeclares org. fetch profile
with the given name in this session.
|
| public Query | enableFetchProfile(String
the name of the fetch profile to be enabled profileName)Redeclares org. fetch profile
for this query.
|
| public int | Returns: the number of affected entity instances (may differ from the number of affected rows)Redeclares org. |
| public String | Returns: The comment.Redeclares org. |
| public LockOptions | Returns: TheLockOptions currently in effectRedeclares org. LockOptions in effect for this query.
|
| public ParameterMetadata | Returns: information about query parameters.Access to information about query parameters. |
| public QueryOptions | Returns: Return the encapsulation of this query's options.Get the execution options for this |
| public String | |
| public default List | Returns: the results as a listOverrides default org. Implements jakarta. List.
|
| public default Stream | Returns: The results as aStreamOverrides default org. Stream.
|
| public SharedSessionContract | Returns: The producer of this queryGet the |
| public R | Returns: the single result, only if there is exactly oneRedeclares org. |
| public List | Returns: the result listRedeclares org. List.
|
| public ScrollableResults | scroll()
Redeclares org. |
| public ScrollableResults | scroll(ScrollMode scrollMode)
Redeclares org. |
| public Query | setCacheable(boolean cacheable)
Redeclares org. |
| public Query | setCacheMode(CacheMode cacheMode)
Redeclares org. CacheMode in effect for this query.
|
| public Query | setCacheRegion(String cacheRegion)
Redeclares org. isCacheable).
|
| public Query | setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode)
Redeclares org. |
| public Query | setCacheStoreMode(CacheStoreMode cacheStoreMode)
Redeclares org. |
| public Query | Returns: this, for method chainingThe human-readable comment comment)Redeclares org. |
| public Query | setEntityGraph(EntityGraph<R> graph, GraphSemantic semantic)
Redeclares org. EntityGraph to the query.
|
| public Query | setFetchSize(int
the fetch size hint fetchSize)Redeclares org. |
| public Query | setFirstResult(int
position of the first result,
numbered from 0 startPosition)Redeclares org. |
| public Query | setFlushMode(FlushModeType
flush mode flushMode)Redeclares org. |
| public Query | setHibernateFlushMode(FlushMode flushMode)
Redeclares org. FlushMode in effect for this query.
|
| public Query | setHint(String
name of property or hint hintName, Object value for the property or hint value)Redeclares org. |
| public Query | Returns: this, for method chainingA query alias alias, LockMode The lock mode to apply lockMode)Redeclares org. LockMode to use for particular alias defined in
the FROM clause of the query.
|
| public Query | setLockMode(LockModeType
lock mode lockMode)Redeclares org. LockModeType for the query
|
| public Query | Returns: this, for method chainingThe lock options to apply to the query. lockOptions)Apply the given lock options to this query. |
| public Query | setMaxResults(int
maximum number of results to retrieve maxResult)Redeclares org. |
| public Query | |
| public Query | setOrder(Order<? super R>
an instance of order)OrderRedeclares org. |
| public default Query | setPage(Page page)
Implements org. |
| public Query | setParameter(String
parameter name parameter, Object parameter value argument)Redeclares org. |
| public <P> Query | setParameter(String parameter, P argument, Class<P> type)
Redeclares org. BindableType
to use.
|
| public <P> Query | setParameter(String parameter, P argument, BindableType<P> type)
Redeclares org. BindableType.
|
| public Query | setParameter(String parameter, Instant argument, TemporalType temporalType)
Redeclares org. Instant value to the named query parameter using
just the portion indicated by the given TemporalType.
|
| public Query | setParameter(String
parameter name parameter, Calendar parameter value argument, TemporalType temporal type temporalType)Redeclares org. jakarta. override
|
| public Query | setParameter(String
parameter name parameter, Date parameter value argument, TemporalType temporal type temporalType)Redeclares org. jakarta. override
|
| public Query | setParameter(int
position parameter, Object parameter value argument)Redeclares org. |
| public <P> Query | setParameter(int parameter, P argument, Class<P> type)
Redeclares org. BindableType
to use.
|
| public <P> Query | setParameter(int parameter, P argument, BindableType<P> type)
Redeclares org. BindableType.
|
| public Query | setParameter(int parameter, Instant argument, TemporalType temporalType)
Redeclares org. Instant value to the ordinal query parameter using
just the portion indicated by the given TemporalType.
|
| public Query | setParameter(int
position parameter, Date parameter value argument, TemporalType temporal type temporalType)Redeclares org. jakarta. override
|
| public Query | setParameter(int
position parameter, Calendar parameter value argument, TemporalType temporal type temporalType)Redeclares org. jakarta. override
|
| public <T> Query | Returns: this, for method chainingthe query parameter memento parameter, T the argument, which might be null argument)Redeclares org. QueryParameter.
|
| public <P> Query | Returns: this, for method chainingthe query parameter memento parameter, P the argument, which might be null argument, Class<P> a type)BindableType representing the type of the parameterRedeclares org. QueryParameter using the given Class reference to attempt to
determine the BindableType to use.
|
| public <P> Query | Returns: this, for method chainingthe query parameter memento parameter, P the argument, which might be null argument, BindableType<P> an type)BindableType representing the type of the parameterRedeclares org. QueryParameter using the given BindableType.
|
| public <T> Query | setParameter(Parameter<T>
parameter object parameter, T parameter value argument)Redeclares org. jakarta. override
|
| public Query | setParameter(Parameter<Calendar>
parameter object parameter, Calendar parameter value argument, TemporalType temporal type temporalType)Redeclares org. jakarta. override
|
| public Query | setParameter(Parameter<Date>
parameter object parameter, Date parameter value argument, TemporalType temporal type temporalType)Redeclares org. jakarta. override
|
| public Query | Returns: this, for method chainingRedeclares org. |
| public <P> Query | Returns: this, for method chainingRedeclares org. BindableType
to use.
|
| public <P> Query | Returns: this, for method chainingRedeclares org. BindableType.
|
| public Query | Returns: this, for method chainingRedeclares org. |
| public <P> Query | Returns: this, for method chainingRedeclares org. BindableType
to use.
|
| public <P> Query | Returns: this, for method chainingRedeclares org. BindableType.
|
| public Query | Returns: this, for method chainingRedeclares org. |
| public <P> Query | Returns: this, for method chainingRedeclares org. BindableType
to use.
|
| public <P> Query | Returns: this, for method chainingRedeclares org. BindableType.
|
| public Query | Returns: this, for method chainingRedeclares org. |
| public <P> Query | Returns: this, for method chainingRedeclares org. Class reference to attempt to determine the BindableType
to use.
|
| public <P> Query | Returns: this, for method chainingRedeclares org. BindableType.
|
| public <P> Query | Returns: this, for method chainingthe parameter memento parameter, Collection<? extends P> a collection of arguments arguments)Redeclares org. QueryParameter.
|
| public <P> Query | Returns: this, for method chainingRedeclares org. QueryParameter using the given Class reference to attempt to
determine the BindableType to use.
|
| public <P> Query | Returns: this, for method chainingRedeclares org. QueryParameter, inferring the BindableType.
|
| public <P> Query | Returns: this, for method chainingthe parameter memento parameter, P[] a collection of arguments arguments)Redeclares org. QueryParameter.
|
| public <P> Query | Returns: this, for method chainingRedeclares org. QueryParameter using the given Class reference
to attempt to determine the BindableType to use.
|
| public <P> Query | Returns: this, for method chainingRedeclares org. QueryParameter, inferring the BindableType.
|
| public Query | Returns: this, for method chainingany JavaBean or POJO bean)Redeclares org. |
| public Query | Returns: this, for method chaininga bean)Map of names to argumentsRedeclares org. Map for each named parameters of
the query, matching key names with parameter names and mapping value
types to Hibernate types using heuristics.
|
| public Query | setReadOnly(boolean
true 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 modeRedeclares org. Query.
|
| public Query | |
| public default <T> Query | setResultTransformer(ResultTransformer<T> transformer)
Deprecated
since 5.2. Use
setTupleTransformer or setResultListTransformer
|
| public Query | setTimeout(int
the timeout in seconds timeout)Redeclares org. |
| public <T> Query | |
| public default Stream | Returns: The results as aStreamOverrides default org. Stream.
|
| public R | Returns: the single result ornull if there is no result to returnRedeclares org. null if the query returns no results.
|
| public Optional | Returns: the single result as anOptionalRedeclares org. Optional.
|