The goal of this sample application is to demonstrate how to browse, insert and update an entity that is based on a table with a VARRAY attribute.
You must have JDeveloper 10g and access to an Oracle
database with the Oracle common schema installed on it. If you do not
have the common schemas installed, follow
these instructions. This sample depends on the
oe_conn connection as defined in those instructions.
To run the sample right-click on the View project and select Run from the context menu.
Note: The output will appear in JDeveloper's Log window. Make sure you have it open to see the output.
The Model project was created using the simple ADF Business Components wizards available in the new gallery. The test client was created using the code editor.
The key point in this sample is showing how you can work with a VARRAY datatype, both querying the values of the VARRAY, and setting values in the VARRAY.
The sample also includes a domain in the Model project for the CUST_ADDRESS_TYP Oracle object datatype in the CUSTOMERS table.
In TestClient.java, on line 36, we set phoneAttr (a oracle.jbo.domain.Array) to the array of the phone numbers in the current row. Then in lines 41 through 44 we loop through all the values in that array and print them using System.out.println.
In lines 48-61, we add an extra number to an exiting VARRAY. In lines 48-54, we get the values of a single row. In line 55, we add an Object to the array representing the phone numbers. In lines 58-61, we add a new value to the array.
The next section of code (lines 68-81) does a similar task, but instead of adding a number to an existing row's VARRAY, it creates a new row and add phone numbers to the new row's VARRAY.
The CUST_ADDRESS column in the CUSTOMERS table uses an Oracle object datatype called CUST_ADDRESS_TYP. While creating the other business components for this sample, JDeveloper created a custom domain called CustAddressTyp that allows us to access all the values in that custom datatype. For more information on this type of domain, see the online help topic "Representing Column Objects as Business Components".