Skip Headers
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3)
B13593-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
 

Configuring a Default Null Value at the Mapping Level

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 mapping level, TopLink uses it to translate in two directions:

Table 35-6 summarizes which mappings support this option.


Note:

A default null value must be an Object. To specify a primitive value (such as int), you must use the corresponding Object wrapper (such as Integer).

You can also use TopLink to set a default null value for all mappings used in a session (see "Configuring a Default Null Value at the Login Level").

Using TopLink Workbench

To configure a default null value for a mapping, use this procedure.

  1. Select the mapped attribute in the Navigator. Its properties appear in the Editor.

  2. Click the General tab. The General tab appears.

    Figure 35-6 General Tab, Default Null Value Options

    Description of Figure 35-6  follows
    Description of "Figure 35-6 General Tab, Default Null Value Options"

Use the following information to complete the Default Null Value fields on the tab:

Field Description
Default Null Value Specify if this mapping contains a default value in the event that the data source is null. If selected, you must enter both the Type and Value of the default.
    Type Select the Java type of the default value.
    Value Enter the default value.

Using Java

To configure a mapping null value using Java API, use the AbstractDirectMapping method setNullValue.

For example:

// Defaults a null salary to 0
salaryMapping.setNullValue(new Integer(0));