5.4. Collection Custom Classes

Before you can access collections using a SQLJ program, you must create custom classes for the collection types using JPublisher. (Details on the use of JPublisher are provided in Chapter 4.) This section shows you how to create the custom classes for the VARRAY and nested table collection types described in this chapter.

The custom classes created for VARRAY and nested table collection types will contain accessor and mutator methods. These methods, which you will learn more about later in this chapter, allow your SQLJ programs to access and modify the collection elements stored in the database tables.

To get JPublisher to generate classes for all the collection and object types created in the object_user schema by the object_user_schema.sql script, run the following command:

jpub -user=object_user/object_password

Table 5-1 shows the types for which JPublisher will generate custom classes, along with descriptions of what the types are used for. The table also lists the specific files generated by JPublisher.

Table 5-1. The custom classes
Type Usage Files generated
t_address Address objects TAddress.sqlj, TAddressRef.java
t_address2 VARRAYs that contain VARCHAR2 strings TAddress2.java
t_address3 VARRAYs that contain t_address objects TAddress3.java
t_address4 Nested tables that contain VARCHAR2 strings TAddress4.java
t_customer Customer objects (used in the previous chapter) TCustomer.sqlj, TCustomerRef.java
t_product Product ...

Get Java Programming with Oracle SQLJ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.