Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
102 lines (84 sloc) 3.15 KB
/// Use or operation of this code is subject to acceptance of the license available in the code repository for this code.
/// This sample persistent class represents a person.
Class Sample.Person Extends (%Persistent, %Populate, %XML.Adaptor)
Parameter EXTENTQUERYSPEC = "Name,SSN,Home.City,Home.State";
/// Define a unique index for <property>SSN</property>.
Index SSNKey On SSN [ Type = index, Unique ];
/// Define an index for <property>Name</property>.
Index NameIDX On Name [ Data = Name ];
/// Define an index for embedded object property <b>ZipCode</b>.
Index ZipCode On Home.Zip [ Type = bitmap ];
/// Person's name.
Property Name As %String(POPSPEC = "Name()") [ Required ];
/// Person's Social Security number. This is validated using pattern match.
Property SSN As %String(PATTERN = "3N1""-""2N1""-""4N") [ Required ];
/// Person's Date of Birth.
Property DOB As %Date(POPSPEC = "Date()");
/// Person's home address. This uses an embedded object.
Property Home As Address;
/// Person's office address. This uses an embedded object.
Property Office As Address;
/// Person's spouse. This is a reference to another persistent object.
Property Spouse As Person;
/// A collection of strings representing the person's favorite colors.
Property FavoriteColors As list Of %String(JAVATYPE = "java.util.List", POPSPEC = "ValueList("",Red,Orange,Yellow,Green,Blue,Purple,Black,White""):2");
/// Person's age.<br>
/// This is a calculated field whose value is derived from <property>DOB</property>.
Property Age As %Integer [ Calculated, SqlComputeCode = { Set {Age}=##class(Sample.Person).CurrentAge({DOB})
}, SqlComputed, SqlComputeOnChange = DOB ];
/// This class method calculates a current age given a date of birth <var>date</var>.
/// This method is used by the Age calculated field.
ClassMethod CurrentAge(date As %Date = "") As %Integer [ CodeMode = expression ]
/// A sample class query that defines a result set that returns Person data
/// ordered by <property>Name</property>.<br>
/// This query can be used within another method (using
/// dynamic SQL), or it can be used from Java.<br>
/// This query is also accessible from JDBC and/or ODBC as the SQL stored procedure
/// <b>SP_Sample_By_Name</b>.
Query ByName(name As %String = "") As %SQLQuery(CONTAINID = 1, SELECTMODE = "RUNTIME") [ SqlName = SP_Sample_By_Name, SqlProc ]
FROM Sample.Person
Storage Default
<Data name="PersonDefaultData">
<Value name="1">
<Value name="2">
<Value name="3">
<Value name="4">
<Value name="5">
<Value name="6">
<Value name="7">
<Value name="8">
You can’t perform that action at this time.