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.Deprecated.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.The flush mode for this query.boolean
Whether the results should be loaded in read-only mode.int
The query timeout in seconds.
-
Element Details
-
-
flushMode
FlushModeType flushModeThe 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
Deprecated.The cache interaction mode for this query.- See Also:
- Default:
- NORMAL
-
readOnly
boolean readOnlyWhether the results should be loaded in read-only mode. Default isfalse
.- Default:
- false
-
cacheStoreMode()
andcacheRetrieveMode()
sinceCacheModeType
is deprecated