| Oracle TopLink Developer's Guide 10g Release 3 (10.1.3) B13593-01 |
|
![]() Previous |
![]() Next |
A default null value is the Java Object type and value that TopLink uses instead of null when TopLink reads a null value from a data source.
When you configure a default null value at the login level, it applies to all mappings used in a session. In this case, TopLink uses it to translate in one direction only: when TopLink reads null from the data source, it converts this null to the specified type and value.
You can also use TopLink to set a default null value on a per-mapping basis (see "Configuring a Default Null Value at the Mapping Level").
|
Note: A default null value must be anObject. To specify a primitive value (such as int), you must use the corresponding Object wrapper (such as Integer). |
Using Java API, you can configure a default null value for all mappings used in a session with the DatabaseLogin method setDefaultNullValue(Class,Object).
For example:
// Defaults all null String values read from the database to empty String
session.getLogin().setDefaultNullValue(String, "");