docs.intersystems.com
Using Caché Objects
Swizzling
[Home] [Back] [Next]
InterSystems: The power behind what matters   
Search:    

Swizzling
If you open (load into memory) an instance of a persistent object, and use an object that it references, then this referenced object is automatically opened. This process is referred to as swizzling; it is also sometimes known as “lazy loading.”
For example, the following code opens an instance of Sample.Employee object and automatically swizzles (opens) its related Sample.Company object by referring to it using dot syntax:
 // Open employee "101"
 Set emp = ##class(Sample.Employee).%OpenId(101)

 // Automatically open Sample.Company by referring to it:
 Write "Company: ",emp.Company.Name,!
 
When an object is swizzled, it is opened using the default concurrency value of Atomic read.
A swizzled object is removed from memory as soon as no objects or variables refer to it.


Send us comments on this page
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA