Skip Headers

# Type Conversion Converter

Previous

Next

The type conversion converter is an extension of direct and direct collection mappings that lets you explicitly map a data source type to a Java type. For example, a `Number` in the data source 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 data source.

Figure: Type Conversion Mapping (relational) illustrates a type conversion mapping (relational). 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).

Type Conversion Mapping (relational)

Description of "Type Conversion Mapping (relational) "

Figure: Type Conversion Mapping (nonrelational) illustrates a type conversion mapping (nonrelational). `java.util.Date` object is mapped to a String in a XML schema.

Type Conversion Mapping (nonrelational)

Description of "Type Conversion Mapping (nonrelational)"

You can use a type conversion converter to specify the specific database type when that type must be handled specially for the database. This includes support for the special Oracle JDBC binding options required for `NCHAR`, `NVARCHAR2`, and `NCLOB` fields as well as the special Oracle Thin JDBC insert and update requirements for handling `BLOB` and `CLOB` fields greater than 5K.

TopLink uses the `NCharacter`, `NClob` and `NString` types in the `oracle.toplink.platform.database.oracle` package as the converter data type to support the `NCHAR`, `NCLOB` and `NVARCHAR2` types. TopLink uses the `java.sql.Blob` and `Clob` types as the converter data type to support `BLOB` and `CLOB` values greater than 5K.

You can configure a type conversion converter to map a data source time type (such as `TIMESTAMP`) to a `java.lang.String` provided that the String value conforms to the following formats:

- `YYYY/MM/DD HH:MM:SS`

- `YY/MM/DD HH:MM:SS`

- `YYYY-MM-DD HH:MM:SS`

- `YY-MM-DD HH:MM:SS`

For more complex `String` to `TIMESTAMP` type conversion, consider a transformation mapping (see "Transformation Mappings").

For more information, see "Configuring a Type Conversion Converter".