Skip Headers
Oracle Fusion Middleware Developer's Guide for Oracle TopLink
11g Release 1 (11.1.1)

Part Number B32441-03
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Go to next page
View PDF

25 Creating an Object-Relational Data Type Descriptor

This chapter describes how to create relational and object-relational data type descriptors.

This chapter includes the following sections:

For information on how to create more than one type of descriptors, see Chapter 118, "Creating a Descriptor".

25.1 Introduction to Object-Relational Data Type Descriptor Creation

After you create a descriptor, you must configure its various options (see Chapter 119, "Configuring a Descriptor") and use it to define mappings.

For complete information on the various types of mapping that TopLink supports, see Chapter 17, "Introduction to Mappings" and Chapter 120, "Creating a Mapping".

For complete information on the various types of descriptor that TopLink supports, see Section 16.1, "Descriptor Types".

For more information, see Chapter 24, "Introduction to Object-Relational Data Type Descriptors".

25.2 Creating an Object-Relational Data Type Descriptor

You cannot create an object-relational data type descriptor using Oracle JDeveloper or TopLink Workbench: you must use Java code. For more information on creating descriptors in Java code, see the Oracle Fusion Middleware Java API Reference for Oracle TopLink.

For more information, see Section 24.1, "Object-Relational Data Type Descriptors".

25.2.1 How to Create an Object-Relational Data Type Descriptor Using Java

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 TopLink uses if your object-relational data type data source driver uses JDBC indexed arrays.

Example 25-1 shows an Employee object that is mapped to an Oracle Database using its object-relational data type features.

Example 25-1 Employee Class

public class Employee {
    Long id;
    String firstName;
    String lastName;


Example 25-2 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 25-2 Employee Object-Relational Data Type Data Model

                                 F_NAME VARCHAR2(100),
                                 L_NAME VARCHAR2(100),) NOT FINAL;

Example 25-3 shows how to code an object-relational data type descriptor in Java to describe the object-relational data type database type Employee_t.

Example 25-3 Creating an Object-Relational Data Type Descriptor in Java

import oracle.toplink.objectrelational.*;
ObjectRelationalDescriptor descriptor = new ObjectRelationalDescriptor();
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 Chapter 26, "Configuring an Object-Relational Data Type Descriptor".

For more information on the object-relational data type mappings that TopLink supports, see Chapter 40, "Introduction to Object-Relational Data Type Mappings".