This topic describes how the generator maps the constructors, methods, fields, and variables in a Java class to PL/SQL. The information presented in this topic is summarized in the Java to PL/SQL Mappings: Quick Reference Table.
For each public constructor in the class, a PL/SQL function called new is created.
If the constructor has parameters, then the new function for that constructor
has the same parameters. The new function returns a new object of type ORA_JAVA.JOBJECT
which represents the newly instantiated Java object.
For each public method with a return type of void, a PL/SQL procedure of the same name is created. If the method has parameters, then the procedure has the same parameters. The parameters will be typed using the mappings described in the documentation.
For each public method with a return type that is not void, a PL/SQL function of the same name is created. If the method has parameters, then the function has the same parameters. The return type of the function will map directly to the return type of the Java method using the type mappings described in the documentation.
For each public, static variable defined in the Java class, a PL/SQL package variable is created of the same name. When the PL/SQL package is first initialized, the value of the variable is extracted from the Java class and the PL/SQL package variable is set. When a variable in a Java class is declared as static and final then it becomes a constant.
The way a public field is mapped depends on the value of the Include get/set for public fields checkbox in the Import Java Class Options dialog. If this check box is selected then Public field is mapped to:
AND
If the public field is an instance field, then the instance of the class is passed as first argument to the function and procedure. If a static field, the instance argument is not necessary.
If the Include get/set for public fields checkbox is clear, then no PL/SQL code is generated.
The PL/SQL Generator performs type translations when it generates the PL/SQL packages from the Java methods. Some examples of this type translation are:
String
in the specified Java class are always mapped to PL/SQL varchar2
types in the generated PL/SQL package.java.lang.String
parameter or return type
is always mapped to an ORA_JAVA.JOBJECT
type in the generated
PL/SQL package. For a more details on the type translation that occurs in a PL/SQL package at generation time, see Java to PL/SQL Type Mapping: Quick Reference Table.