Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Using Caché Objects - InterSystems Documentation
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>Objects</strong> and SQL<br />
13.2.2.4 Reference Properties<br />
Reference properties (that is, references to other persistent objects) are projected as fields<br />
containing the ID portion of the OID of the referenced object. For instance, suppose a customer<br />
object has a Rep property that refers to a SalesRep object (who is the customer' s sales representative).<br />
If a particular customer has a sales representative with an ID of 12, then the entry<br />
in the Rep column for that customer is also 12. Since this value matches that of the particular<br />
row of the ID column of the referenced object, you can use this value when performing any<br />
joins or other processing.<br />
Note that within <strong>Caché</strong> SQL you can use a special reference syntax to easily use such references<br />
without cumbersome JOIN syntax. For example:<br />
SELECT Company->Name FROM Sample.Employee ORDER BY Company->Name<br />
13.2.2.5 Embedded Object Properties<br />
An embedded object property is projected as multiple columns in the parent class' table. One<br />
column in the projection contains the entire object in serialized form (including all delimiters<br />
and control characters). The rest of the columns are each for one property of the object.<br />
The name of the column for the object property is the same as that of the object property<br />
itself. The other column names are made up of the name of the object property, an underscore,<br />
and the property within the embedded object. For instance, suppose a class has a Home<br />
property containing an embedded object of type Address; Home itself has properties that<br />
include Street and Country. The projection of the embedded object then includes the columns<br />
named “Home_Street” and “Home_Country” . (Note that the column names are derived<br />
from the property, Home, and not the type, Address.)<br />
For example, the sample class Sample.Person, includes a Home property which is an<br />
embedded object of type Sample.Address. You can use the component fields of Home via<br />
SQL as follows:<br />
SELECT Name, Home_City, Home_State FROM Sample.Person<br />
WHERE Home_City %STARTSWITH 'B'<br />
ORDER BY Home_City<br />
Embedded objects can also include other complex forms of data:<br />
• The projection of a reference property includes a read-only field that includes the object<br />
reference as described in “Reference Properties” .<br />
• The projection of an array is as a single, non-editable column that is part of the class'<br />
table.<br />
118 <strong>Using</strong> <strong>Caché</strong> <strong>Objects</strong>