Oracle8i JDBC Developer's Guide and Reference
Release 3 (8.1.7)

Part Number A83724-01





Go to previous page Go to beginning of chapter Go to next page

Using JPublisher to Create Custom Object Classes

A convenient way to create custom object classes, as well as other kinds of custom Java classes, is to use the Oracle JPublisher utility. It generates a full definition for a custom Java class, which you can instantiate to hold the data from an Oracle object. JPublisher-generated classes include methods to convert data from SQL to Java and from Java to SQL, as well as getter and setter methods for the object attributes.

This section offers a brief overview. For more information, see the Oracle8i JPublisher User's Guide.

JPublisher Functionality

You can direct JPublisher to create custom object classes that implement either the SQLData interface or the CustomDatum interface, according to how you set the JPublisher type mappings.

If you use the CustomDatum interface, JPublisher will also create a custom reference class to map to object references for the Oracle object type. If you use the SQLData interface, JPublisher will not produce a custom reference class; you would use standard java.sql.Ref instances instead.

If you want additional functionality, you can subclass the custom object class and add features as desired. When you run JPublisher, there is a command-line option for specifying both a generated class name and the name of the subclass you will implement. For the SQL-Java mapping to work properly, JPublisher must know the subclass name, which is incorporated into some of the functionality of the generated class.


Hand-editing the JPublisher-generated class, instead of subclassing it, is not recommended. If you hand-edit this class and later have to re-run JPublisher for some reason, you would have to re-implement your changes.  

JPublisher Type Mappings

JPublisher offers various choices for how to map user-defined types and their attribute types between SQL and Java. The rest of this section lists categories of SQL types and the mapping options available for each category.

For general information about SQL-Java type mappings, see "Datatype Mappings".

For more information about JPublisher features or options, see the Oracle8i JPublisher User's Guide.

Categories of SQL Types

JPublisher categorizes SQL types into the following groups, with corresponding JPublisher options as noted:

Type-Mapping Modes

JPublisher defines the following type-mapping modes, two of which apply to numeric types only:

Mapping the SQL Object Type to Java

Use the JPublisher -usertypes option to determine how JPublisher will implement the custom Java class that corresponds to a SQL object type:

The next section discusses type mapping options that you can use for object attributes.


You can also use JPublisher with a -usertypes=oracle setting in creating CustomDatum implementations to map SQL collection types.

The -usertypes=jdbc setting is not valid for mapping SQL collection types. (The SQLData interface is intended only for mapping SQL object types.)  

Mapping Attribute Types to Java

If you do not specify mappings for the attribute types of the SQL object type, JPublisher uses the following defaults:

If you want alternate mappings, use the -numbertypes, -lobtypes, and -builtintypes options as necessary, depending on the attribute types you have and the mappings you desire.

If an attribute type is itself a SQL object type, it will be mapped according to the -usertypes setting.


Be especially aware that if you specify a SQLData implementation for the custom object class and want the code to be portable, you must be sure to use portable mappings for the attribute types. The defaults for numeric types and built-in types are portable, but for LOB types you must specify -lobtypes=jdbc.  

Summary of SQL Type Categories and Mapping Settings

Table 8-1 summarizes JPublisher categories for SQL types, the mapping settings relevant for each category, and the default settings.

Table 8-1 JPublisher SQL Type Categories, Supported Settings, and Defaults
SQL Type Category  JPublisher Mapping Option  Mapping Settings  Default 

UDT types  


oracle, jdbc  


numeric types  


oracle, jdbc, objectjdbc, bigdecimal  


LOB types  


oracle, jdbc  


built-in types  


oracle, jdbc  



The JPublisher -mapping option used in previous releases will be deprecated but is currently still supported. For information about how JPublisher converts -mapping option settings to settings for the new mapping options, see the Oracle8i JPublisher User's Guide.  

Go to previous page
Go to beginning of chapter
Go to next page
Copyright © 1996-2000, Oracle Corporation.

All Rights Reserved.