Representing a VARRAY that Contains Oracle Object Types

If you have a VARRAY that contains Oracle Object Types, you must create a domain only for the Oracle Object Type. In the following example, an Oracle Object Type Project is defined. Project objects are then used as the elements of a ProjectList VARRAY type. The department table is defined to have a projects column of type ProjectList; that is, a VARRAY whose elements are Oracle Objects of type Project.

CREATE TYPE Project AS OBJECT( --create object
  project_no NUMBER(2),
  title VARCHAR2(35),
  cost NUMBER(7,2));
/
CREATE TYPE ProjectList AS VARRAY(50) OF Project;
/
CREATE TABLE department ( -- create database table
  dept_id NUMBER(2) PRIMARY KEY,
  name VARCHAR2(15),
  budget NUMBER(11,2),
  projects ProjectList ); -- declare varray as column
/

To use the table as an entity object, you must create a domain only for Project. A domain is not needed for ProjectList—JDeveloper can provide the mapping from a VARRAY to a Java class.


Related topics
Ways to Represent Oracle Object Types in Entity Objects
Representing an Oracle Object Type with a User-defined Domain
Replacing an Oracle Object Type with a REF to a Table of that Type
About Generating Entity Objects, Associations, and Database Tables
What Is an Entity Object?
What Is an Entity Attribute?
Business Component Data Types