| Oracle9iAS TopLink Mapping Workbench Reference Guide Release 2 (9.0.3) Part Number B10063-01 |
|
When you create a descriptor for a class, the Mapping Workbench retrieves the table information from the database.
Each Mapping Workbench project contains a database. You can create multiple logins for each database.
Use the Database properties to specify information about the database and login(s).
You must log into the database before importing or exporting table information.
Click on the database object in the Project Tree pane and click on the Login button
in the toolbar. The Mapping Workbench logs into the database. The database object in the Project Tree pane changes to
.
You can also log into the database by right-clicking on the database object and selecting Log In from the pop-up menu or Selected > Log in from the menu.
|
Note: f you have not defined a login, the system displays a warning message. See "Database Properties" for more information on creating a database login. |
When you expand the database object in the Project Tree pane, the Mapping Workbench displays the database tables associated with the project. You can associate tables by importing them from the database or by creating them within the Mapping Workbench.
Database pane icons called out in Figure 3-2:
Each database table contains the following tabs in the Properties pane:
Use this procedure to create a new database table within the Mapping Workbench.
. The New Table window appears.
You can also create a new table by right-clicking on the database object and selecting Add New Table from the pop-up menu or Selected > Add New Table from the menu.
| Field | Description |
|---|---|
|
Schema |
Use these fields to identify specific database information for the table. Consult your database administrator for more information. |
|
Table Name |
Name of this database table. |
Refer to "Generating Tables on the Database" to add the table information to the database.
Note:
Continue with "Working with Database Tables in the Properties Pane" to use these tables in your project.
The Mapping Workbench can automatically read the schema for a database and import the table data into the project.
To retrieve table information from the database, the database driver must support the following JDBC methods:
. The Import tables from database window appears.
You can also import tables from the database by right-clicking on the database object in the Project Tree and selecting Add/Update Existing Tables from Database from the pop-up menu or Selected > Add/Update Existing Tables from Database from the menu.
User-interface components called out in Figure 3-4:
. TopLink adds the table to the Selected Tables field.
Use this procedure to remove a database table from the project.
in the toolbar. The Mapping Workbench prompts for confirmation.
You can also remove a database table from the project by right-clicking on the database object and selecting Remove from the pop-up menu or Selected > Remove Table from the menu.
Use this procedure to rename a database table in the Mapping Workbench project.
You can also rename the table by choosing the table and selecting Selected > Rename from the menu.
When you select a database table in the Project Tree pane, its properties appear in the Properties pane. Each database table contains the following property tabs:
Use the database table's Field tab to specify properties for the database table's fields.
To remove a field, select the field and click on Remove.
Use this procedure to set primary key(s) for a database table.
References are table properties that contain the foreign key - they may or may not correspond to an actual constraint that exists on the database. The Mapping Workbench uses these references when you define relationship mappings and multiple table associations.
When importing tables from the database (see "Importing Tables from Database"), the Mapping Workbench can automatically create references (if the driver supports this) or you can define references from the workbench.
Continue with Creating Field References.
The Mapping Workbench can automatically generate the following information from the database tables.
You can also generate database tables from descriptors in your project.
Use this procedure to automatically generate SQL scripts to create the tables in a project.
You can also generate SQL scripts by selecting Selected > Generate Creation Script for > Selected Table or All Tables from the menu.
The Mapping Workbench can automatically generate Java class definitions, descriptor definitions, and associated mappings from the information in database tables. You can later edit the generated information, if necessary.
For each table, the Mapping Workbench will:
You can also generate SQL scripts by selecting Selected > Generate Descriptors and Classes from > Selected Table or All Tables from the menu.
| Field | Description |
|---|---|
|
Package Name |
Name of package to generate |
|
Generate Accessing Methods |
Specify if the Mapping Workbench generates accessing methods for each class and descriptor |
or 1:M Mapping
button. See Chapter 6, "Understanding Relationship Mappings" for more information on mappings.
You can also specify if the relationships are bidirectional.
The newly created descriptors appear in the Project Tree pane of the Mapping Workbench.
Use this procedure to create a table on the database, based on the information in the Mapping Workbench.
You can also create tables by selecting Selected > Create on Database > Selected Table or All Tables from the menu.
|
Note: You must log into the database before creating tables. See "Logging into the Database" for more information. |
The Mapping Workbench creates the tables on the database.
Use this procedure to automatically generate EJB classes and descriptors for each database table. Generating EJB entities allows you to create:
<javax.ejb.EntityBean> interface and four EJB 1.1 classes for each table
You can also create entities by selecting Selected > Generate EJB Entities and Descriptors from > Selected Table or All Tables from the menu.
or 1:M Mapping
button.
You can also specify if the relationships are bi-directional.
The system creates the remote primary key, home, and bean classes for each bean and adds this information to the project. The newly created descriptor(s) appear in the Project Tree pane of the Mapping Workbench. Use the EJB Info tab to modify the EJB information.
|
|
![]() Copyright © 2002 Oracle Corporation. All Rights Reserved. |
|