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


@NamedStoredFunctionQuery

Use @NamedStoredFunctionQuery to define queries that call stored functions as named queries.


Annotation Elements

Table 2-39 describes this annotation's elements.

Table 2-39 @NamedStoredFunctionQuery Annotation Elements

Annotation Element Description Default

functionName

(Required) The name of the stored function.


name

(Required) The unique name that references this stored function query.


returnParamter

(Required) The return value of the stored function.


callByIndex

(Optional) Specifies if the stored function should be called by index or by name.

  • If by index, the parameters must be defined in the same order as the procedure on the database.

  • If by name, you must use the database platform support naming procedure parameters

false

hints

(Optional) Query hints


parameters

(Optional) The parameters for the stored function.


resultSetMapping

(Optional) The name of the SQLResultMapping.




Usage

You can specify @NamedStoredFunctionQuery on an Entity or MappedSuperclass.


Examples

Example 2-71 shows how to use this annotation.

Example 2-71 Using @NamedStoredFunctionQuery Annotation

@Entity
@Table(name="CMP3_ADDRESS")
 
@NamedStoredFunctionQuery(
  name="StoredFunction_In",
  functionName="StoredFunction_In",
  parameters={
    @StoredProcedureParameter(direction=IN, name="P_IN", queryParameter="P_IN", type=Long.class)
    },
  returnParameter=@StoredProcedureParameter(queryParameter="RETURN", type=Long.class)
  )
public class Address implements Serializable {
...
}

Example 2-72 shows how to use the <named-stored-function-query> element in the eclipselink-orm.xml file.

Example 2-72 Using <named-stored-function-query> XML

<named-stored-function-query name="StoredFunction_In" procedure-name="StoredFunction_In">
    <parameter direction="IN" name="P_IN" query-parameter="P_IN" type="Long"/>
</named-stored-function-query>


See Also

For more information, see: