Chapter 16. Strongly Typed Object SQL
Strongly typed
object SQL refers to the use of client-side
custom Java classes to manipulate database-side SQL objects. The
classes themselves are referred to as
custom
because a Java class is created to
mirror its database counterpart. To mirror database objects you can
use one of two approaches: the JDBC API’s standard
SQLData
interface or Oracle’s
CustomDatum
interface. With the
SQLData
interface, a database object is
represented as a custom Java class that implements the
SQLData
interface; however, a collection is still
represented by an Array
object, and a reference is
still represented by a Ref
object. With the Oracle
CustomDatum
interface, a database object is
represented as an Oracle custom class file that implements the
CustomDatum
and
CustomDatumFactory
interfaces. Unlike the
SQLData
interface, The
CustomDatum
interface supports all database object
types, including references and collections.
For example, in Chapter 15 we used a
Struct
object to manipulate a database object, an
Array
object for collections, and a
Ref
object to hold a database reference. With
strongly typed object SQL, you’ll use a custom Java class to
manipulate a database object, an Array
object or
another custom Java class for a collection, and a
Ref
object or yet another custom Java class to
hold a database reference.
If you’re concerned with portability, then you should use the
SQLData
interface. Otherwise, since the
SQLData
interface currently doesn’t provide ...
Get Java Programming with Oracle JDBC 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.