Use @NamedStoredProcedureQuery
to define queries that call stored procedures as named queries.
Annotation Elements
Table 2-41 describes this annotation's elements.
Table 2-41 @NamedStoredProcedureQuery Annotation Elements
Annotation Element | Description | Default |
---|---|---|
|
(Required) Unique name that references this stored procedure query. |
|
|
(Required) Name of the stored procedure |
|
|
(Optional) Specifies if the stored procedure should be called by name.
|
|
|
(Optional) An array of query hints. |
|
|
(Optional) Specifies if the stored procedure returns multiple result sets. This applies only for databases that support multiple result sets from stored procedures. |
|
|
(Optional) An array of parameters for the stored procedure |
|
|
(Optional) The class of the result |
|
|
(Optional) Name of the |
|
|
(Optional) Specifies if the stored procedure retainers a result set This applies only for databases that support result sets from stored procedures. |
|
Usage
You can specify @NamedStoredProcedureQuery
on an Entity or MappedSuperclass.
Examples
Example 2-74 shows how to use @NamedStoredProcedureQuery
to define a stored procedure.
Example 2-74 Using @NamedStoredProcedureQuery Annotation
@NamedStoredProcedureQuery(name="findAllEmployees", procedureName="EMP_READ_ALL", resultClass=Employee.class, parameters={ @StoredProcedureParameter(queryParameter="result", name="RESULT_CURSOR", direction=Direction.OUT_CURSOR}) @Entity public class Employee { ... }
Example 2-75 shows how to use the <named-stored-procedure-query>
element in the eclipselink-orm.xml
file.
Example 2-75 Using <named-stored-procedure-query> XML
<named-stored-procedure-query name="SProcXMLInOut" result-class="Address" procedure-name="SProc_Read_XMLInOut"> <parameter direction="IN_OUT" name="address_id_v" query-parameter="ADDRESS_ID" type="Long"/> <parameter direction="OUT" name="street_v" query-parameter="STREET" type="String"/> </named-stored-procedure-query>
See Also
For more information, see:
"Stored Procedures" in Understanding EclipseLink
"Stored Procedures Examples"
http://wiki.eclipse.org/EclipseLink/Examples/JPA/StoredProcedures