@Repeatable(NamedNativeQueries.class)
@Target(TYPE)
@Retention(RUNTIME)
public @interface NamedNativeQuery
Declares a named native SQL query and, optionally, the mapping
of the result of the native SQL query. Query names are scoped
to the persistence unit. The
NamedNativeQuery annotation
can be applied to an entity or mapped superclass.- Since:
- 1.0
- See Also:
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionThe name used to refer to the query with theEntityManagermethods that create query objects.The SQL query string. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionSpecifies the result set mapping to constructors.Specifies the result set mapping to scalar values.Specifies the result set mapping to entities.Query properties and hints.Class<?>The class of the result.The name of aSqlResultSetMapping, as defined in metadata.
-
Element Details
-
name
String nameThe name used to refer to the query with theEntityManagermethods that create query objects. -
query
String queryThe SQL query string. -
hints
QueryHint[] hintsQuery properties and hints. (May include vendor-specific query hints.)- Default:
- {}
-
resultClass
Class<?> resultClassThe class of the result.- Default:
- void.class
-
resultSetMapping
String resultSetMappingThe name of aSqlResultSetMapping, as defined in metadata.- Default:
- ""
-
entities
EntityResult[] entitiesSpecifies the result set mapping to entities. May not be used in combination withresultSetMapping().- Since:
- 3.2
- Default:
- {}
-
classes
ConstructorResult[] classesSpecifies the result set mapping to constructors. May not be used in combination withresultSetMapping().- Since:
- 3.2
- Default:
- {}
-
columns
ColumnResult[] columnsSpecifies the result set mapping to scalar values. May not be used in combination withresultSetMapping().- Since:
- 3.2
- Default:
- {}
-