Handling_Null_Values - TransferORM/transfer GitHub Wiki

Handling Null Values

Retrieving NULL Value

Since ColdFusion does not have native support for 'null' values, if a NULL value is stored in the database, configurable values are assigned when a NULL value in the database is retrieved.

The default values set to a TransferObject property when as NULL value in the database are found are:

Type Value Comment
numeric 0 Interpreted as a empty value, hence 0
string '' Interpreted as an empty value, hence the empty string
date 1-January-0100 This is the earliest date ColdFusion can create.
boolean false NULL is not True, hence it is false.
UUID 00000000-0000-0000-0000000000000000 UUID with only 0's
GUID 00000000-0000-0000-0000-000000000000 GUID with only 0's
binary [] An empty byte array

These values can be overwritten by the 'nullValues' element in the Transfer Configuration File, as well as with the '@nullValue' attribute on an individual 'property' element, but only if the 'nullable' attribute on the property is set to 'true'.

If the property value equals the configured NULL value, the 'getproperty[@name]IsNull()' will return 'true'.

Inserting Null Values

If Transfer finds the value of the 'property' is the same as the configured Null value for that property, and 'nullable' is set to 'true' it will insert a NULL value into the database instead of the actual value of the property.

The shorthand way to set the TransferObject's property to the configured NULL value is by calling the 'setproperty[@name]Null()' method on the TransferObject.

Foreign Keys

Transfer will also INSERT or UPDATE NULL values in the Foreign Key of a manytoone Child if it has not been set or in the Foreign key of a onetomany parent that has not been set.

⚠️ **GitHub.com Fallback** ⚠️