Oracle® Application Server TopLink Mapping Workbench User's Guide
10g Release 2 (10.1.2) Part No. B15900-01 |
|
Previous |
Next |
Type conversion mappings explicitly map a database type to a Java type. For example, a Number
in the database can be mapped to a String
in Java, or a java.util.Date
in Java can be mapped to a java.sql.Date
in the database.
For Oracle9 databases, OracleAS TopLink supports NCHAR, NAVRCHAR2, and NCLOB database types. Use the Ncharacter
, NString
, and NClob
target types, respectively.
Example 5-2 Type Conversion Mapping Example
Figure 5-3 illustrates a type conversion mapping. Because the java.util.Date class is stored by default as a Timestamp in the database, it must first be converted to an explicit database type such as java.sql.Date (required only for DB2— most other databases have a single date data-type that can store any date or time).
Use this procedure to create a type conversion mapping.
To create a type conversion mapping:
Select the attribute to be mapped from the Navigator pane.
Description of the illustration tcmapbtn.gif
Click the Type Conversion Mapping button on the mapping toolbar.
From the Database field and Database type drop-down lists on the General tab in the Editor pane, choose the appropriate database field and database type.
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