TOC Special:Whatlinkshere_Creating_an_Object-Relational_Data_Type_Descriptor_(ELUG)[Related Topics]
After you create a descriptor, you must configure its various options (see Configuring a Descriptor) and use it to define mappings.
For complete information on the various types of mapping that EclipseLink supports, see Introduction to Mappings and Creating a Mapping.
For complete information on the various types of descriptor that EclipseLink supports, see Descriptor Types.
For more information, see Introduction to Object-Relational Data Type Descriptors.
You cannot create an object-relational data type descriptor using the Workbench: you must use Java code. For more information on creating descriptors in Java code, see the EclipseLink API Reference.
For more information, see Object-Relational Data Type Descriptors.
Use the ObjectRelationalDescriptor
class to define an
object-relational data type descriptor. This class extends
RelationalDescriptor
to add the following methods:
-
setStructureName
: call this method to set the name of the object-relational data type structure that represents the object class in the data source. -
addFieldOrdering
: call this method repeatedly to define the order in which object attributes are persisted to the data source. This defines a field index that EclipseLink uses if your object-relational data type data source driver uses JDBC indexed arrays.
This example shows an Employee
object that is mapped to an Oracle
Database using its object-relational data type features.
[Example 30-1]# Employee Class
public class Employee {
Long id;
String firstName;
String lastName;
...
}
This example shows the object-relational data type database type
(Employee_t
) created to model the Employee
object within the
database. Such an object-relational data type database type is also
known as a structure. This example also shows how to create and populate
a database table (called department
) that stores instances of the
Employee_t
audio tape.
[Example 30-2]# Employee Object-Relational Data Type Data Model
CREATE TYPE EMPLOYEE_T AS OBJECT(ID NUMBER(10),
F_NAME VARCHAR2(100),
L_NAME VARCHAR2(100),) NOT FINAL;
CREATE TABLE EMPLOYEES OF EMPLOYEE_T;
This example shows how to code an object-relational data type descriptor
in Java to describe the object-relational data type database type
Employee_t
.
[Example 30-3]# Creating an Object-Relational Data Type Descriptor in Java
import org.eclipse.persistence.mappings.structures.*;
...
ObjectRelationalDescriptor descriptor = new ObjectRelationalDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setTableName("EMPLOYEES");
descriptor.setStructureName("EMPLOYEE_T");
descriptor.setPrimaryKeyFieldName("ID");
descriptor.addFieldOrdering("ID");
descriptor.addFieldOrdering("F_NAME");
descriptor.addFieldOrdering("L_NAME");
descriptor.addDirectMapping("id", "OBJECT_ID");
descriptor.addDirectMapping("firstName", "F_NAME");
descriptor.addDirectMapping("lastName", "L_NAME");
For more information on configuring object-relational data type descriptors, see Configuring an Object-Relational Data Type Descriptor.
For more information on the object-relational data type mappings that EclipseLink supports, see Introduction to Object-Relational Data Type Mappings.
Category:_EclipseLink_User’s_Guide[Category: EclipseLink User’s Guide] Category:_Release_1[Category: Release 1] Category:_Task[Category: Task] Category:_ORM[Category: ORM]