Package org.hibernate.annotations
Annotation Interface NamedNativeQuery
@Target({TYPE,PACKAGE})@Retention(RUNTIME)@Repeatable(NamedNativeQueries.class)public @interfaceNamedNativeQuery
Declares a named query written in native SQL.
WhereasNamedNativeQuery allows settings to be specified using stringly-typedQueryHints, this annotation is typesafe.
Note that the members of this annotation correspond to hints enumerated byAvailableHints.
- See Also:
Required Element Summary
Required ElementsOptional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanWhether 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 SQL query.intThe number of rows fetched by the JDBC driver per trip.Determines whether the session should be flushed before executing the query.Deprecated, for removal: This API element is subject to removal in a future version.useflush()String[]Thequery spaces involved in this query.booleanWhether the results should be loaded in read-only mode.Class<?>The resultingClass.The name of aSqlResultSetMapping.intThe 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, for removal: This API element is subject to removal in a future version.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[] querySpacesThequery spaces involved in this query.Typically, the names of tables which are referenced by the query.
- See Also:
- Default:
- {}