Code Generation
Introduction
This section explains:
Code
Generation Tabs
To
display the code generation options, the last entry in the tree on the left
hand side of the window should be selected. |
Selecting
The Classes To Generate Or Verify
The Code Generation uses the following tab set:
- Java Sources Root Folder: Use this button to popup Swing's File
selection dialog. Select the folder (do not open it) which is the
root of your project files. The wizard will create any subfolders to
match any packages you have specified for your Java classes.
- Available Classes This "multiple selection" list box
shows all the classes currently not scheduled for generation. Select
those that you would like to generate, then press the arrow button
- Use These "multiple selection" list box shows all the
classes currently scheduled for generation. Select those that you would not
like to generate or verify, then press the arrow button
- Arrow Buttons allow you to earmark
classes for code generation, or no code generation
EJB
Setup
The EJB Setup tab contains settings which affect all the generated BMP EJB's.
- Datasource JNDI name specifies the datasource the implementation
ejb's should use. This information is usually in the EJB container.
- DataSource <res-ref-name> is used in the generated manifest.
Each ejb is declared to use the datasource resource reference.
- Do not Generate Transactions determines if the manifest contains
transaction information.
- Override Bean Transactions can set the transactions for all the
generated beans' home interface methods, and remote interface methods.
- Generate Bean Transactions causes the wizard to generate many
transaction entries, in the manifest file. One entry per bean method is
generated (including property get and set methods)
- Save saves all changes made on this tab.
Specifying
The Code Style
This tab allows the style of the code generated to be specified. If any
changes are made to the fields, the Save button should be pressed.
- Brace radio buttons are used to
specify how the generated Java code should place the opening braces '{'
in the code
- Tab as Tab determines if a tab character or spaces should be used
to indent the code.
- Tab Length is used if spaces are selected to indent the code,
this field specifies the number of spaces each indentation should be.
- Save,
the Save button should be pressed to save all changes made.
Specifying
The File Locations
The above tab can be used to specify where the java code files should be generated.
The folder (or directory) can be selected by pressing the "..." button,
or the location can be entered in the textfiled. The folder can be relative
to the project file's location, or a fully qualified path (absolute path).
Verifying
Classes
When coding against databases, there is the danger that the database schema
has been changed. This can cause programs to stop working correctly. Finding
the problem used to be tough. The wizard can check the classes against the database
for you. Any possibly problematic changes are reported.
The following Warnings are issued:
- 99 The wizard is not connected to the database. Most problems will
go undetected when disconnected.
- 100 The column or stored procedure parameter is new. The database
object (table, view...) should be inspected, and the class viewed. This will
cause the wizard to generate the new column in the class. Each class must
be viewed individually to get the wizard to add the new column to each class.
- 101 The column has changed type in the database. The column/stored
procedure parameter should be reviewed. Pressing the synchronize button causes
the wizard to hold the new type. Then each class should be reviewed, to make
sure the class property type is correct.
- 102 The column's nullable status has changed. The column/stored
procedure parameter should be reviewed. Pressing the synchronize button causes
the wizard to hold the new type. Then each class should be reviewed, to make
sure the class property type is correct.
- 103 The column has been dropped from the database. The column/stored
procedure parameter needs to be deleted in the wizard. Pressing the delete
button causes the wizard to remove the column from the project file. Then
each class should be reviewed, this causes the wizard to remove the column
from the class. It is advisable to review classes' sql methods, in case they
use this in the Where, Order By... clauses.
- 104 The column is no longer in the database, and no longer in
the wizard's tree, however, the class still references the column. The
class should be reviewed, this forces the wizard to remove the column from
the class. It is advisable to review classes' sql methods, in case they use
this in the Where, Order By... clauses.
- 105 the stored procedure's IN/INOUT/OUT/RETURN status has changed.
The stored procedure parameter should be reviewed. Pressing the synchronize
button causes the wizard to hold the new parameter type. Then each class should
be reviewed, to make sure the class reflects the new access type..
The following link explains in more detail
how to manage changes in the database. The use of the Synchronize and Delete
buttons is discussed.
Generating
The Code
To generate code, the "Generate Code" button needs to be pressed.
A status is displayed to show what classes are currently being generated, and
if any problems have occurred.
Anytime a file already exists, it is renamed with an extension of .xja
- To see how to use the generated JDBC Classes click here.
- To see how to use the generated JDBC stored procedure classes click
here.
- To see how to use the generated BMP EJB classes click here.
Copyright © 2002 J3
Limited, all rights reserved.