/// 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 ({
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
/// Person's Social Security number. This is validated using pattern match.
Property SSN As
/// Person's Date of Birth.
Property DOB As
/// 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
/// Person's age.<br>
/// This is a calculated field whose value is derived from <property>DOB</property>.
Property Age As }, 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 {
$Select(date="":"",1:($ZD($H,8)-$ZD(date,8)\10000))
}
/// 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 {
SELECT ID, Name, DOB, SSN
FROM Sample.Person
WHERE (Name ORDER BY Name
}
Storage Default
{
<Data name="PersonDefaultData">
<Value name="1">
<Value></Value>
<Value name="2">
<Value>Name</Value>
</Value>
<Value name="3">
<Value>SSN</Value>
</Value>
<Value name="4">
<Value>DOB</Value>
</Value>
<Value name="5">
<Value>Home</Value>
</Value>
<Value name="6">
<Value>Office</Value>
</Value>
<Value name="7">
<Value>Spouse</Value>
</Value>
<Value name="8">
<Value>FavoriteColors</Value>
</Value>
</Data>
<DataLocation>^Sample.PersonD</DataLocation>
<DefaultData>PersonDefaultData</DefaultData>
<IdLocation>^Sample.PersonD</IdLocation>
<IndexLocation>^Sample.PersonI</IndexLocation>
<StreamLocation>^Sample.PersonS</StreamLocation>
<Type>}
}