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.Extends
NamedNativeQuerywith additional settings.- See Also:
NativeQuery
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description booleancacheableWhether the query results are cacheable.CacheModeTypecacheModeDeprecated.StringcacheRegionIf the query results are cacheable, the name of the query cache region.jakarta.persistence.CacheRetrieveModecacheRetrieveModeThe cache retrieval mode for objects returned by this query.jakarta.persistence.CacheStoreModecacheStoreModeThe cache storage mode for objects returned by this query.booleancallableDeprecated.Calling database procedures and functions throughNativeQueryis no longer supported; useNamedStoredProcedureQueryinstead.StringcommentA comment added to the SQL query.intfetchSizeThe number of rows fetched by the JDBC driver per trip.FlushModeTypeflushModeThe flush mode for the query.String[]querySpacesThe query spaces involved in this query.booleanreadOnlyWhether the query results should be marked read-only.Class<?>resultClassThe resultingClass.StringresultSetMappingThe name of aSqlResultSetMapping.inttimeoutThe query timeout in seconds.
-
-
-
Element Detail
-
name
String name
The name of this query.- See Also:
EntityManagerFactory.addNamedQuery(java.lang.String, jakarta.persistence.Query),Session.createNamedQuery(java.lang.String, java.lang.Class<R>)
-
-
-
query
String query
The text of the SQL query.
-
-
-
resultClass
Class<?> resultClass
The resultingClass. Should not be used in conjunction withresultSetMapping()- Default:
- void.class
-
-
-
resultSetMapping
String resultSetMapping
The name of aSqlResultSetMapping. Should not be used in conjunction withresultClass().- Default:
- ""
-
-
-
flushMode
FlushModeType flushMode
The flush mode for the query.- Default:
- org.hibernate.annotations.FlushModeType.PERSISTENCE_CONTEXT
-
-
-
cacheable
boolean cacheable
Whether the query results are cacheable. Default isfalse, that is, not cacheable.- See Also:
SelectionQuery.setCacheable(boolean)
- Default:
- false
-
-
-
cacheRegion
String cacheRegion
If the query results are cacheable, the name of the query cache region.- See Also:
SelectionQuery.setCacheRegion(String)
- Default:
- ""
-
-
-
fetchSize
int fetchSize
The number of rows fetched by the JDBC driver per trip.- See Also:
SelectionQuery.setFetchSize(int)
- Default:
- -1
-
-
-
timeout
int timeout
The query timeout in seconds. Default is no timeout.- See Also:
CommonQueryContract.setTimeout(int)
- Default:
- -1
-
-
-
comment
String comment
A comment added to the SQL query. Useful when engaging with DBA.- See Also:
CommonQueryContract.setComment(String)
- Default:
- ""
-
-
-
cacheStoreMode
jakarta.persistence.CacheStoreMode cacheStoreMode
The cache storage mode for objects returned by this query.- See Also:
Query.setCacheMode(CacheMode)
- Default:
- jakarta.persistence.CacheStoreMode.USE
-
-
-
cacheRetrieveMode
jakarta.persistence.CacheRetrieveMode cacheRetrieveMode
The cache retrieval mode for objects returned by this query.- See Also:
Query.setCacheMode(CacheMode)
- Default:
- jakarta.persistence.CacheRetrieveMode.USE
-
-
-
cacheMode
@Deprecated(since="6.2") CacheModeType cacheMode
Deprecated.The cache interaction mode for this query.- Default:
- org.hibernate.annotations.CacheModeType.NORMAL
-
-
-
readOnly
boolean readOnly
Whether the query results should be marked read-only. Default isfalse.- See Also:
SelectionQuery.setReadOnly(boolean)
- Default:
- false
-
-
-
querySpaces
String[] querySpaces
The query spaces involved in this query.- See Also:
SynchronizeableQuery
- Default:
- {}
-
-
-
callable
@Deprecated(since="6.0") boolean callable
Deprecated.Calling database procedures and functions throughNativeQueryis no longer supported; useNamedStoredProcedureQueryinstead.Is the SQL query a call to a stored procedure or function?- Default:
- false
-
-