In the top-down mapping approach, you generate a default
database schema and mapping based on one or more existing enterprise
beans. The enterprise beans is required to be at either EJB 1.1, 2.0,
or 2.1 specification-level. The EJB to RDB mapping tools do not support
using enterprise beans at EJB 3.0 specification-level.
About this task
To generate a schema and map from existing enterprise
beans using the top-down mapping approach:
Procedure
- In the Enterprise Explorer
view of the Java™ EE perspective,
select any of the following options:
- EJB project
- Deployment Descriptor identified with an EJB JAR icon
- Right-click and then select .
Restriction: To use the EJB to RDB mapping wizard, you must
close any of the following editors that might be opened for a particular
EJB project:
- EJB Deployment Descriptor for editing the ejb-jar.xml file
- Mapping for editing the Map.mapxmi file
- Physical Data Model (also known as SQL Model editor) for editing
the databaseName.dbm file
- For EJB 2.x projects, select whether to Create
a new backend folder or to Use an existing
backend folder. If you choose to use an existing backend,
and if you have previously generated a mapping, you must choose one
of the following options:
- Create and map unmapped elements:
use this option if you have changed the backend or to the enterprise
beans and want to create the new elements and update the map accordingly.
- Open mapping editor on selected backend map:
use this option to open the mapping editor, where you can make manual
updates to the mapping.
Click Finish to perform the action and
exit the wizard.
- If you choose to create a new backend folder, click Next to
continue creating your initial top-down mapping.
- Select Top-Down, and click Next.
- Select a Target Database.
- Type the Database name and Schema name.
- Optional: You can select one or both of the
following check boxes:
- Generate DDL
- Add a column for collision detection:
Use this option for EJB 2.x CMP beans to add a column to your relational
table. This column is reserved to determine if a record has been updated.
For more information about this collision detection column, refer
to the related topic about adding a column for collision detection.
- Click Finish to create the top-down
mapping, or click Next to further define inheritance.
- If inheritance exists, select additional enterprise beans
from the list to add a leaf table for each checked bean that joins
with the parent table, then click Finish.
Results
The EJB mapping tools create tables, columns, and constraints
relating to a CMP bean and its fields, as well as a map of each CMP
field to a column. You can then make any required changes to these
maps using the Mapping editor. Use the relational database tools to
modify the tables and columns.