Oracle’s CustomDatum Interface
In this section, you will learn how to use Oracle’s
CustomDatum interface classes to manipulate
database objects. However, since we covered the
SQLData interface in great detail, and there are
minimal differences between the CustomDatum
classes and the SQLData classes, I won’t get
into nearly as much detail as I did with SQLData.
Oracle’s CustomDatum
interface classes created by
JPublisher are for one-stop shopping. When you use JPublisher with
the option -usertypes=oracle, it creates custom
classes for all the database data types you specify, including
references and collections, and also creates wrapper methods for
static and member type methods. In addition, if you use
CustomDatum, no type map is required.
If you specify methods=true or
methods=named, JPublisher generates
.sqlj files instead of
.java files. The .sqlj
files then need to be compiled using SQLJ to create the
corresponding
.java files. The default constructor for the
generated classes uses the SQLJ default Context
for a connection -- you don’t want to use this. Instead, use
one of the alternate constructors, that is, one that takes a
Connection as an argument. Let’s go ahead
and start generating CustomDatum classes. Our
first concern will be creating an appropriate input file.
Creating an Input File for CustomDatum
The mapping
input file for generating
CustomDatum classes is different from the one we
used for SQLData. First, since JPublisher can generate the methods for us, we no longer ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access