Package org.hibernate.annotations
Annotation Interface NamedNativeQuery
@Target({TYPE,PACKAGE})
@Retention(RUNTIME)
@Repeatable(NamedNativeQueries.class)
public @interface NamedNativeQuery
Declares a named query written in native SQL.
Whereas NamedNativeQuery
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.boolean
Deprecated.A comment added to the 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.useflush()
String[]
The query spaces involved in this query.boolean
Whether the results should be loaded in read-only mode.Class<?>
The resultingClass
.The name of aSqlResultSetMapping
.int
The query timeout in seconds.
-
Element Details
-
-
resultClass
Class<?> resultClassThe resultingClass
.Should not be used in conjunction with
resultSetMapping()
- Default:
- void.class
-
resultSetMapping
String resultSetMappingThe name of aSqlResultSetMapping
.Should not be used in conjunction with
resultClass()
.- Default:
- ""
-
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 the 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 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
-
querySpaces
String[] querySpacesThe query spaces involved in this query.Typically, the names of tables which are referenced by the query.
- See Also:
- Default:
- {}
-
callable
Deprecated.Calling database procedures and functions throughNativeQuery
is no longer supported; useNamedStoredProcedureQuery
instead.Is the SQL query a call to a stored procedure or function?- See Also:
- Default:
- false
-
NativeQuery
is no longer supported; useNamedStoredProcedureQuery
instead.