Skip Headers
Oracle® Application Server TopLink Mapping Workbench User's Guide
10g Release 2 (10.1.2)
Part No. B15900-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Creating Tables

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.

Creating Tables Using the OracleAS TopLink Mapping Workbench

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.

Creating the Table Definitions

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:

  1. Add New Table button.
    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.

  2. Type ADDRESS for the table name, and click OK.


    Note:

    Leave the Catalog and Schema fields blank.

  3. Click the Fields tab in the Editor pane.

  4. 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.

    Figure B-14 Database Fields Tab

    Description of fldaddr.gif follows
    Description of the illustration fldaddr.gif

  5. Save button.
    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.

Creating the Tables on the Database

After defining the tables in OracleAS TopLink Mapping Workbench, you can automatically create the tables on the database.

To create tables on the database:

  1. 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)

  2. Click OK to close the dialog box and return to the OracleAS TopLink Mapping Workbench window.

  3. Logout of Database button.
    Description of the illustration logotbtn.gif

    On the toolbar, click the Logout of Database button or choose Selected > Log Out from the menu.

  4. Save your changes. Click the Save Project button Save 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.


Importing Tables from the Database

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:

  1. Login to Database button.
    Description of the illustration loginbtn.gif

    Click the Login to Database button or choose Selected > Login from the menu.

  2. Add or Update Existing Tables button
    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 Import Tables from Database

    Description of importdb.gif follows
    Description of the illustration importdb.gif

    Figure B-15 calls out the following user-interface elements:

    1. Use the filters to specify database tables to select for import.

    2. The Available Tables displays the database tables that match the filter.

  3. 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.

  4. Select the ADDRESS Select button.
    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.

  5. Repeat Step 4 for the EMPLOYEE and PHONE tables.

  6. Click OK to add the selected tables to the Employee project.

  7. To display the details of the imported tables, select a table in the Navigator pane and click the Fields tab in the Editor pane.

  8. Log out of database button.
    Description of the illustration logotbtn.gif

    Click the Log Out of Database button or choose Selected > Log Out of Database from the menu.

  9. Save Project button.
    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".