Oracle® Application Server TopLink Mapping Workbench User's Guide
10g Release 2 (10.1.2) Part No. B15900-01 |
|
Previous |
Next |
You can enter database table information (as "Creating the Database Schema" specifies) directly from OracleAS TopLink Mapping Workbench or import the tables from the database.
To create the tables from OracleAS TopLink Mapping Workbench, continue with "Creating Tables Using the OracleAS TopLink Mapping Workbench".
To create the tables by importing from the database, continue with "Importing Tables from the Database".
Use this procedure to create the database tables from the OracleAS TopLink Mapping Workbench.
Caution: Do not use this procedure if you plan to import the tables from a database. |
Use this procedure to create table definitions using the OracleAS TopLink Mapping Workbench. Later, you can create the actual tables on the database.
To create the tables:
Description of the illustration addtable.gif
Select the database in the Navigator pane and click the Add New Table button or right-click the database in the Navigator pane, and choose Add New Table. The New Table dialog box appears.
Type ADDRESS
for the table name, and click OK.
Note: Leave the Catalog and Schema fields blank. |
Click the Fields tab in the Editor pane.
Click Add to add each database field for the ADDRESS
table. Refer to the tables in "Creating the Database Schema" for the correct field information. Be sure to indicate the primary key(s) for each table.
Note: Use the scroll bar to view additional fields for each database field (such as the Primary Key). See "Preparing the Primary Keys" for more information. |
Description of the illustration savebtn.gif
Save your changes. Click the Save Project button or choose File > Save from the menu.
Repeat this procedure for the EMPLOYEE
and PHONE
tables.
After defining the tables in OracleAS TopLink Mapping Workbench, you can automatically create the tables on the database.
To create tables on the database:
Right-click one of the database tables in the Navigator pane, and choose Create on Database > All Tables from the pop-up menu. The system displays a message indicating that the three tables were created.
Note: To use the Create on Database option, you must be logged into the database. |
If the Confirm Replace dialog box appears, it means that an existing table on the database has the same name. Check with your database administrator before replacing any table. The existing table may have been created by:
Someone else doing the tutorial previously (in which case you could click the Yes to All button safely)
Someone using the same database name for a business project (in which case you should not replace it)
Click OK to close the dialog box and return to the OracleAS TopLink Mapping Workbench window.
Description of the illustration logotbtn.gif
On the toolbar, click the Logout of Database button or choose Selected > Log Out from the menu.
Save your changes. Click the Save Project button
Description of the illustration savebtn.gif
or choose File > Save from the menu.
Continue with "Mapping Classes and Tables in the Descriptor".
Note: OracleAS TopLink Mapping Workbench can generate Data Definition Language (DDL) creation scripts that can be used to create tables on the desired database.If the table creation fails, there might have been a problem with the DDL, or you may not have permission to create tables on the database. Make sure you set the target database to the correct database platform on login. Because the DDL may not be compatible with some databases, you may have to edit the generated DDL and execute the DDL manually. In addition, ensure that the Database Platform field on the Database property sheet (see Figure B-13) matches your database driver information. |
Use this procedure if you have already created tables in your database and want to import these tables directly into the OracleAS TopLink Mapping Workbench.
Caution: Do not use this procedure if you plan to create the tables directly from OracleAS TopLink Mapping Workbench. |
To import tables from the database:
Description of the illustration loginbtn.gif
Click the Login to Database button or choose Selected > Login from the menu.
Description of the illustration addtbldb.gif
Select the database in the Navigator pane and click the Add or Update Existing Tables from Database button, or right-click the database and choose Add or Update Existing Tables From Database from the pop-up menu.
The Import tables from database dialog box appears.
Figure B-15 calls out the following user-interface elements:
Use the filters to specify database tables to select for import.
The Available Tables displays the database tables that match the filter.
Click the Get Table Names button to display all tables in the database.
Note: You can use the table filters to specify which database tables are available for import. For this tutorial, leave the filters as their default values. |
Select the ADDRESS
Description of the illustration arrow.gif
table in the Available Tables pane and then click the button. The ADDRESS
table moves to the Selected Tables pane.
Repeat Step 4 for the EMPLOYEE
and PHONE
tables.
Click OK to add the selected tables to the Employee project.
To display the details of the imported tables, select a table in the Navigator pane and click the Fields tab in the Editor pane.
Description of the illustration logotbtn.gif
Click the Log Out of Database button or choose Selected > Log Out of Database from the menu.
Description of the illustration savebtn.gif
Save your changes. Click the Save Project button or choose File > Save from the menu.
Continue with "Mapping Classes and Tables in the Descriptor".