Use @PLSQLRecord to define a database PLSQL RECORD type for use within PLSQL procedures.
Annotation Elements
Table 2-52 describes this annotation's elements.
Table 2-52 @PLSQLRecord Annotation Elements
| Annotation Element | Description | Default |
|---|---|---|
|
|
(Required) The name of the record type in the database. |
|
|
|
(Required) Name of the database |
|
|
|
(Required) The fields in the record type. |
|
|
|
(Optional) The class to which to the object type. You must map this class with the |
Usage
Oracle PLSQL RECORD types are structured database types. Although JDBC does not provide a mechanism for returning these types, EclipseLink provides support to translate these types into OBJECT types. You must create an OBJECT type on the database to mirror the RECORD type and provide it as the compatibileType in the @PLSQLRecord.
You can then map the RECORD to a Java class, map the Java class as an @Embeddable, use the @Struct annotations to map the Java class to the OBJECT type that mirrors the RECORD type.
You can then call and return the Java class as parameters to the PLSQL stored procedure query.
Examples
Example 2-90 shows how to use this annotation.
Example 2-90 Using @PLSQLRecord Annotation
@NamedPLSQLStoredFunctionQuery(name="getEmployee", functionName="EMP_PKG.GET_EMP",
returnParameter=@PLSQLParameter(name="RESULT", databaseType="EMP_PKG.EMP_REC"))
@Embeddable
@Struct(name="EMP_TYPE", fields={"F_NAME", "L_NAME", "SALARY"})
@PLSQLRecord(name="EMP_PKG.EMP_REC", compatibleType="EMP_TYPE", javaType=Employee.class,
fields={@PLSQLParameter(name="F_NAME"), @PLSQLParameter(name="L_NAME"), @PLSQLParameter(name="SALARY", databaseType="NUMERIC_TYPE")})
public class Employee {
...
}
See Also
For more information, see:
"Stored Procedures" in Understanding EclipseLink
Oracle PL/SQL
http://www.oracle.com/technetwork/database/features/plsql/index.html
PLSQL Stored Procedure Examples
http://wiki.eclipse.org/EclipseLink/Examples/JPA/PLSQLStoredFunction