Annotation Interface NamedStoredProcedureQuery
The NamedStoredProcedureQuery annotation can be applied to an
entity or mapped superclass.
The name() element is the name that is passed as an argument
to the EntityHandler.createNamedStoredProcedureQuery(String) method to
create an executable StoredProcedureQuery object. Names are
scoped to the persistence unit.
The procedureName() element is the name of the stored procedure
in the database.
The parameters of the stored procedure are specified by the
parameters() element. Parameters must be specified in the order
in which they occur in the parameter list of the stored procedure.
The resultClasses() element refers to the class (or classes)
that are used to map the results. The resultSetMappings() element
names one or more result set mappings, as defined by the
SqlResultSetMapping annotation.
If there are multiple result sets, it is assumed that they are
mapped using the same mechanism — e.g., either all via a set of
result class mappings or all via a set of result set mappings. The
order of the specification of these mappings must be the same as the
order in which the result sets are returned by the stored procedure
invocation. If the stored procedure returns one or more result sets
and no resultClasses() or resultSetMappings() are
specified, any result set is returned as a list of type
Object[]. The combining of different strategies for the mapping
of stored procedure result sets is undefined.
The hints() element may be used to specify query properties
and hints. Properties defined by this specification must be observed
by the provider. Vendor-specific hints that are not recognized by a
provider must be ignored.
All parameters of a named stored procedure query must be specified
using the StoredProcedureParameter annotation.
- Since:
- 2.1
- See Also:
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionThe name used to refer to the query with theEntityManagermethods that create stored procedure query objects.The name of the stored procedure in the database. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionQuery properties and hints.Information about all parameters of the stored procedure.Class<?>[]The result classes.String[]The names of one or more result set mappings declared in metadata.
-
Element Details
-
name
String nameThe name used to refer to the query with theEntityManagermethods that create stored procedure query objects. -
procedureName
String procedureNameThe name of the stored procedure in the database. -
parameters
StoredProcedureParameter[] parametersInformation about all parameters of the stored procedure. Parameters must be specified in the order in which they occur in the parameter list of the stored procedure.- Default:
{}
-
resultClasses
Class<?>[] resultClassesThe result classes.When the result classes are explicitly specified and the result set mappings are not, either:
- the result class is an entity class and is interpreted as a managed entity result with implicit field mappings determined by the names of the columns in the result set and the object/relational mapping of the entity,
- the result class is the class of a basic type and the result set must have a single column which is interpreted as a scalar result,
- the result class is a non-abstract class or record type with a constructor with the same number of parameters as the result set has columns, and is interpreted as a constructor result including all the columns of the result set, or
- the result class is
Object[].classand each query result is packaged in an array of typeObject[], with the array elements corresponding by position with the columns of the select list and column values obtained according to the default type mappings defined by the JDBC specification.
Otherwise, if result set mappings are specified, each explicitly specified result class must agree with the type inferred from the corresponding result set mapping.
If the result classes are not explicitly specified, then they are inferred from the result set mapping, if any, or default to
ObjectorObject[]. Any result class may be overridden by explicitly passing a class object toStoredProcedureQuery.getResultList(Class),StoredProcedureQuery.getSingleResult(Class), orStoredProcedureQuery.getSingleResultOrNull(Class).- Default:
{}
-
resultSetMappings
String[] resultSetMappingsThe names of one or more result set mappings declared in metadata. The named result set mappings are used to interpret the result sets of the stored procedure.Any result set mapping may be overridden by explicitly passing a
ResultSetMappingtoStoredProcedureQuery.getResultList(ResultSetMapping),StoredProcedureQuery.getSingleResult(ResultSetMapping), orStoredProcedureQuery.getSingleResultOrNull(ResultSetMapping).- See Also:
- Default:
{}
-
hints
QueryHint[] hintsQuery properties and hints. (May include vendor-specific query hints.)- Default:
{}
-