Java Persistence API (JPA) Extensions Reference for EclipseLink, Release 2.5
  Go To Table Of Contents
 Search
 PDFComments
Comments


@NamedStoredProcedureQuery

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

name

(Required) Unique name that references this stored procedure query.


procedureName

(Required) Name of the stored procedure


callByIndex

(Optional) Specifies if the stored procedure should be called by name.

  • If true, the StoredProcedureParameters must be defined in the same order as the procedure on the database

  • If false, the database platform must support naming procedure parameters

false

hints

(Optional) An array of query hints.


multipleResultSets

(Optional) Specifies if the stored procedure returns multiple result sets.

This applies only for databases that support multiple result sets from stored procedures.

false

parameters

(Optional) An array of parameters for the stored procedure


resultClass

(Optional) The class of the result

void.class

resultSetMapping

(Optional) Name of the SQLResultMapping


returnsResultSet

(Optional) Specifies if the stored procedure retainers a result set

This applies only for databases that support result sets from stored procedures.

false



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: