Extending JPublisher-Generated Classes

The Declaration Name and Use Name fields in the JPublisher wizard give you the flexibility of extending generated classes. In the Declaration Name field, enter the name of the class that you want JPublisher to generate from the given database object. In the Use Name field, enter the name of the class that your Java program will use to represent the database object.

When publishing an object type where Use Name is different from Declaration Name, JPublisher creates a declaration_name.sqlj file and a use_nameRef.java file, where use_name represents the object type in your Java program.

JPublisher expects that you have written the class use_name, which extends declaration_name. If you do not provide this class, then the use_nameRef.java file will not compile.

For example, suppose you want JPublisher to generate the class JAddress from the PL/SQL object type ADDRESS. You have also written a class, MyAddress, to represent ADDRESS objects, where MyAddress either extends the functionality provided by JAddress or has a JAddress field.

Under this scenario, select ADDRESS in the Database Browser and right-click Generate Java. In the JPublisher wizard, enter JAddress in the Declaration Name field and MyAddress in the Use Name field. JPublisher will generate the custom Java class JAddress, and map the ADDRESS object to the MyAddress class—not to the JAddress class. JPublisher will also produce a reference class for MyAddress, not JAddress.

This is how JPublisher will alter the code it generates:

The class that you create (for example, MyAddress.java) must have the following features:


Enhancing JPublisher-Generated Classes
Generating Source Code for Oracle Objects and PL/SQL Packages

 

Copyright © 1997, 2004, Oracle. All rights reserved.