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
 

Working with Object Type Mappings

Object type mappings match a fixed number of database values to Java objects. Use these mappings when the values in the database differ from those in Java. Object types mappings are similar to direct-to-field mappings in all other respects.

The following figure illustrates an object type mapping between the Employee attribute gender and the relational database column GENDER. If the gender value in the Java class = Male, the system stores it in the GENDER database field as M; Female is stored as F.

Figure 5-5 Object Type Mappings

Description of obmapfig.gif follows
Description of the illustration obmapfig.gif

Creating Object Type Mappings

Use this procedure to create an object type mapping between an attribute and a database column.

To create a basic object type mapping:

  1. In the Navigator pane, select the attribute to be mapped.

  2. Object-Type Mapping button.
    Description of the illustration obmapbtn.gif

    Click the Object-Type Mapping button on the mapping toolbar. The Object type mapping tab appears in the Editor pane.

    Figure 5-6 Object Type Mapping General Properties

    Description of obmaptab.gif follows
    Description of the illustration obmaptab.gif

  3. Choose the appropriate database field in the Database Field drop-down list.

  4. Select Use Default Value When Database Field is Null to specify a default Type and Value to use if the database field is null.

  5. Set the database type from the Database Type drop-down list and the Java type from the Object type drop-down list.

  6. Click on Add to add Database Value and Object Value pairs to the table. Select the Default Attribute Value option for the value to use as the default.

    To remove a database value, select the value and click Remove.

You can also specify:

  • Read-only attributes – See "Specifying Read-Only Settings" on page 4-72

  • Access methods – See "Specifying Direct Access and Method Access" on page 4-71