Oracle8i SQLJ Developer's Guide and Reference
Release 8.1.5






Prev  Chap Top Next

Weakly Typed Objects, References, and Collections

Weakly typed objects, references, and collections are supported by SQLJ. Their general use is not recommended and there are some specific restrictions, but in some circumstances they may be useful. For example, you may have generic code that can use "any STRUCT" or "any REF" (although if this uses dynamic SQL it would require coding in JDBC instead of SQLJ).

Support for Weakly Typed Objects, References, and Collections

In using Oracle objects, references, or collections in a SQLJ application, you have the option of using generic and weakly typed oracle.sql classes instead of the strongly typed custom Java classes that implement the CustomDatum interface.

The following oracle.sql classes can be used for iterator columns or host expressions in Oracle SQLJ:

In host expressions they are supported as follows:

Using these classes is not generally recommended, however, as you would lose all the advantages of the strongly typed paradigm that SQLJ offers.

Each attribute in a STRUCT object or each element in an ARRAY object is stored in an oracle.sql.Datum object, with the underlying data being in the form of the appropriate oracle.sql.* type (such as oracle.sql.NUMBER or oracle.sql.CHAR). Attributes in a STRUCT object are nameless.

Because of the generic nature of the STRUCT and ARRAY classes, SQLJ cannot do type checking where objects or collections are written to or read from instances of these classes.

It is generally recommended that you use custom Java classes for objects, references, and collections, preferably classes generated by JPublisher.

Restrictions on Weakly Typed Objects, References, and Collections

A weakly typed object (STRUCT instance), reference (REF instance), or collection (ARRAY instance) cannot be used in host expressions in the following circumstances:

They cannot be used in these ways because there is no way to know the underlying SQL type name (such as Person), which is required by the Oracle JDBC driver in order to materialize an instance of a user-defined type in Java.



Copyright © 1999 Oracle Corporation.

All Rights Reserved.