Skip to main content

Introduction to Serial Objects

Introduction to Serial Objects

Serial classes extend %SerialObjectOpens in a new tab. The purpose of such classes is to serve as a property in another object class. The values in a serial object are serialized into the parent object. Serial objects are also called embedded (or embeddable) objects. InterSystems IRIS handles serial object properties differently from non-serial object properties. Two of the differences are as follows:

  • It is not necessary to call %New() to create the serial object before assigning values to properties in it.

  • If the serial object property is contained in a persistent class, the properties of the serial object are stored within the extent of the persistent class.

To define a serial class, simply define a class that extends %SerialObjectOpens in a new tab, and add properties and other class members as needed. The following shows an example:

Class Sample.Address Extends %SerialObject
{

/// The street address.
Property Street As %String(MAXLEN = 80);

/// The city name.
Property City As %String(MAXLEN = 80);

/// The 2-letter state abbreviation.
Property State As %String(MAXLEN = 2);

/// The 5-digit U.S. Zone Improvement Plan (ZIP) code.
Property Zip As %String(MAXLEN = 5);

}
FeedbackOpens in a new tab