Oracle® Application Server TopLink Mapping Workbench User's Guide
10g Release 2 (10.1.2) Part No. B15900-01 |
|
Previous |
Next |
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.
Use this procedure to create an object type mapping between an attribute and a database column.
To create a basic object type mapping:
In the Navigator pane, select the attribute to be mapped.
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.
Choose the appropriate database field in the Database Field drop-down list.
Select Use Default Value When Database Field is Null to specify a default Type and Value to use if the database field is null.
Set the database type from the Database Type drop-down list and the Java type from the Object type drop-down list.
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