Package org.hibernate.annotations
Annotation Type 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-typedQueryHint
s, this annotation is typesafe.Note that the members of this annotation correspond to hints enumerated by
AvailableHints
.- See Also:
NativeQuery
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description boolean
cacheable
Whether the query results are cacheable.@Remove CacheModeType
cacheMode
Deprecated.String
cacheRegion
If the query results are cacheable, the name of the query cache region.CacheRetrieveMode
cacheRetrieveMode
The cache retrieval mode for objects returned by this query.CacheStoreMode
cacheStoreMode
The cache storage mode for objects returned by this query.boolean
callable
Deprecated.Calling database procedures and functions throughNativeQuery
is no longer supported; useNamedStoredProcedureQuery
instead.String
comment
A comment added to the SQL query.int
fetchSize
The number of rows fetched by the JDBC driver per trip.FlushModeType
flushMode
The flush mode for the query.String[]
querySpaces
The query spaces involved in this query.boolean
readOnly
Whether the results should be loaded in read-only mode.Class<?>
resultClass
The resultingClass
.String
resultSetMapping
The name of aSqlResultSetMapping
.int
timeout
The query timeout in seconds.
-
-
-
Element Detail
-
name
String name
The name of this query. Must be unique within a persistence unit.
-
-
-
query
String query
The text of the SQL query.
-
-
-
resultClass
Class<?> resultClass
The resultingClass
.Should not be used in conjunction with
resultSetMapping()
- Default:
- void.class
-
-
-
resultSetMapping
String resultSetMapping
The name of aSqlResultSetMapping
.Should not be used in conjunction with
resultClass()
.- Default:
- ""
-
-
-
flushMode
FlushModeType flushMode
The flush mode for the query.- See Also:
CommonQueryContract.setFlushMode(jakarta.persistence.FlushModeType)
,HibernateHints.HINT_FLUSH_MODE
- Default:
- org.hibernate.annotations.FlushModeType.PERSISTENCE_CONTEXT
-
-
-
cacheRegion
String cacheRegion
If the query results are cacheable, the name of the query cache region.- Default:
- ""
-
-
-
timeout
int timeout
The query timeout in seconds. Default is no timeout.- See Also:
CommonQueryContract.setTimeout(int)
,HibernateHints.HINT_TIMEOUT
,SpecHints.HINT_SPEC_QUERY_TIMEOUT
- Default:
- -1
-
-
-
comment
String comment
A comment added to the SQL query. Useful when engaging with DBA.- Default:
- ""
-
-
-
cacheStoreMode
CacheStoreMode cacheStoreMode
The cache storage mode for objects returned by this query.- Default:
- jakarta.persistence.CacheStoreMode.USE
-
-
-
cacheRetrieveMode
CacheRetrieveMode cacheRetrieveMode
The cache retrieval mode for objects returned by this query.- Default:
- jakarta.persistence.CacheRetrieveMode.USE
-
-
-
cacheMode
@Deprecated(since="6.2") @Remove @Remove CacheModeType cacheMode
Deprecated.The cache interaction mode for this query.- See Also:
HibernateHints.HINT_CACHE_MODE
- Default:
- org.hibernate.annotations.CacheModeType.NORMAL
-
-
-
querySpaces
String[] querySpaces
The query spaces involved in this query.Typically, the names of tables which are referenced by the query.
- See Also:
SynchronizeableQuery.addSynchronizedQuerySpace(java.lang.String)
,HibernateHints.HINT_NATIVE_SPACES
,Synchronize
- Default:
- {}
-
-
-
callable
@Deprecated(since="6.0") boolean 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:
HibernateHints.HINT_CALLABLE_FUNCTION
- Default:
- false
-
-