This task describes how to generate a bottom-up mapping
when you want to create enterprise beans from relational tables. When
the workbench is connected to an existing database or database view,
you can generate a bottom-up mapping to create the enterprise beans. The enterprise beans created are at either EJB
1.1, 2.0, or 2.1 specification-level. The EJB to RDB mapping tools
do not support creating enterprise beans at EJB 3.0 specification-level.
About this task
Steps for this taskTo generate enterprise beans
and map based on a bottom-up mapping approach from a database connection
or view:
Procedure
- In the Data Source Explorer view of the Data perspective,
select any of the following:
- database
- database connection
- specific database tables or views associated with the database
connection
- multiple database views or connections or both
- multiple tables or views or both
- Right-click and select .
- In the EJB project field, you can
type a new project name. If you type a new project name a new EJB
project is created automatically for you when you complete the wizard.
Optionally, click the New button to launch
the New EJB Project wizard if you want to set additional options for
the new project. See the Creating an EJB project topic for detailed instructions
on this page of the wizard. Click Next.
- Select the tables from the database that you want to import
into your project as EJB beans, and click Next. If you selected only a database or database connection in the Data
Source Explorer view, you have to specify which tables are used for
the creation of EJB beans. If you selected specific tables or views
or both, then the check boxes for those tables is already marked.
- In order to avoid broken foreign keys, the wizard imports any
required tables.
- If you plan on using a bean to update a view, make sure that the
view supports updates. The wizard does not check whether a view can
be updated.
- If you are working with an EJB 1.x project, under the CMP Version drop-down list, the EJB specification-level
for generating the enterprise beans defaults to 1.x. If you are working
with an EJB 2.x project, you have the option to select one of the
following under the CMP Version drop-down
list to specify the EJB specification-level for the generated enterprise
beans:
Note: For EJB 2.x enterprise beans, the bottom-up mapping only
generates local interfaces because typically entity beans only contain
local interfaces.
- In the Package for generated EJB classes field, type the package name for the generated enterprise bean
classes.
- Optional: In the Prefix for generated
EJB classes field, you can add a prefix name that gets
added to the unique names generated by the mapping tool to avoid
collision of new table mappings to existing CMP entity beans.
- If you selected to import and map a view, you can choose
whether you want to create additional beans for the tables in the
view. By default, the Do not generate beans for tables
included in views check box is selected, and the wizard
does not create these beans.
Tip: When you
do a bottom-up mapping, by default the wizard does not generate beans
for underlying tables for views. However, because relationships need
to be created for foreign keys, the wizard automatically creates a
bean for any table that has any foreign keys or whose primary key
is pointed to by any foreign keys from other tables. If you clear
the Do not generate beans for tables included in views check box, the wizard generates beans for all tables and views
in the database schema.
- Click Finish to generate the enterprise
beans and the bottom-up mapping based on the database views that you
selected in the wizard.