Package org.hibernate.annotations
Annotation Interface NamedQuery
@Target({TYPE,PACKAGE})
@Retention(RUNTIME)
@Repeatable(NamedQueries.class)
public @interface NamedQuery
Declares a named query written in HQL or JPQL.
Whereas NamedQuery
allows settings to be specified
using stringly-typed QueryHint
s, this annotation
is typesafe.
Note that the members of this annotation correspond to hints enumerated by
AvailableHints
.
- See Also:
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionboolean
Whether the query results are cacheable.The cache interaction mode for this query.If the query results are cacheable, the name of the query cache region.The cache retrieval mode for objects returned by this query.The cache storage mode for objects returned by this query.A comment added to the generated SQL query.int
The number of rows fetched by the JDBC driver per trip.Determines whether the session should be flushed before executing the query.Deprecated.boolean
Whether the results should be loaded in read-only mode.Class<?>
Optional query result class that is used by default when creating the query.int
The query timeout in seconds.
-
Element Details
-
-
resultClass
Class<?> resultClassOptional query result class that is used by default when creating the query. May be overridden by explicitly passing a class object toEntityManager.createNamedQuery(String, Class)
.- See Also:
- Default:
- void.class
-
flush
QueryFlushMode flushDetermines whether the session should be flushed before executing the query.- Since:
- 7.0
- See Also:
- Default:
- DEFAULT
-
flushMode
Deprecated.useflush()
The flush mode for this query.- See Also:
- Default:
- PERSISTENCE_CONTEXT
-
cacheable
boolean cacheableWhether the query results are cacheable. Default isfalse
, that is, not cacheable.- Default:
- false
-
cacheRegion
String cacheRegionIf the query results are cacheable, the name of the query cache region.- Default:
- ""
-
fetchSize
int fetchSizeThe number of rows fetched by the JDBC driver per trip.- Default:
- -1
-
timeout
int timeoutThe query timeout in seconds. Default is no timeout.- See Also:
- Default:
- -1
-
comment
String commentA comment added to the generated SQL query. Useful when engaging with DBA.- Default:
- ""
-
cacheStoreMode
CacheStoreMode cacheStoreModeThe cache storage mode for objects returned by this query.- Default:
- USE
-
cacheRetrieveMode
CacheRetrieveMode cacheRetrieveModeThe cache retrieval mode for objects returned by this query.- Default:
- USE
-
cacheMode
CacheMode cacheModeThe cache interaction mode for this query.- Default:
- NORMAL
-
readOnly
boolean readOnlyWhether the results should be loaded in read-only mode. Default isfalse
.- Default:
- false
-
flush()