Generating a bottom-up mapping for the first time
This task describes how to generate for your first time a bottom-up mapping. Bottom-up approach assumes that the database tables already exist, and that once the selected tables are imported, the enterprise beans and mappings between them are automatically generated. By default, relationships are generated where foreign-keys exist.
Prerequisite tasks
- Enable the J2EE and Database Capabilities. You can complete this as follows:
- In the workbench preferences page (Window > Preferences) expand the folder Workbench , select Capabilites.
- Under the Capabilities list, select the Enterprise Java check box underAdvanced J2EE. Click OK.
Steps for this task
To generate enterprise beans and map based on a bottom-up mapping approach:
- In the workspace toolbar, select File > New > Other. Expand the EJB folder, and select Enterprise Beans from Tables. Click Next.
- Complete the Database Connection page and click Next. See Creating JDBC connections for detailed instructions on this page of the wizard. If you have already completed this step once, you can select the Use existing connection check box and select an existing connection from the drop-down list.
- In the EJB project combination box, you can type a new project name or select an existing enterprise application project from the drop-down list. If you type a new project name, a new EJB project will be created automatically for you when you click the Next button. Optionally, click the New... button to launch the New EJB Project wizard if you wish to set additional options for the new project. See Creating an EJB project for detailed instructions on this page of the wizard.
- Select the tables and views from the database that you want to import, and click Next.
- 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:
- 1.x
- 2.x
Note: For EJB 2.x enterprise beans, the bottom-up mapping only generates local interfaces because it is normally considered best practice for entity beans to only contain local interfaces.
- In the Package for generated EJB classes field, type the package name for the generated EJB 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 or not 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 will 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 schemata.- Click Finish to generate the enterprise beans and the bottom-up mapping based on the database tables and views that you selected in the wizard.
Parent topic
Generating a bottom-up mapping
Feedback