User's Manual

Chapter 9. Persistence Tutorial 69
DataCollections are also useful when it is necessary to perform certain tasks on a large number
of Data Objects. Suppose you want to add the publications to a java.util.Collection that can then be
passed around. The following code will create the java.util.Collection (remove the "\" and make it all
one line):
DataCollection publication = SessionManager.getSession().retrieve\
("tutorial.Publication");
Collection collection = new ArrayList();
pub.addFilter(pub.getFilterFactory().addLessThan("id", new Integer(100), \
false));
while (pub.next()) {
collection.add(pub.getDataObject());
}
Note
Please note the following:
Most creation of Data Objects should be handled through the use of Domain Objects. All ACSOb-
jects are also DomainObjects and therefore can use the DomainObject API to retrieve the correct
information. For more information, please see the Section 10.2 Domain Objects Tutorial.
The DataCollection class does NOT extend the java.util.Collection interface, nor does it extend
the java.util.Iterator interface.
9.2.6. Object Type Inheritance
Now that you know how to create and access information for a specific object type, the next logical
step in Object-Oriented programming is to create an object type that extends another object type. To
address this problem, PDL allows object types to inherit attributes from other object types, similar to
inheritance in most Object-Oriented programming languages.
The following example shows a "Magazine" object type extending the "Publication" object type. The
definition for the "Magazine" is very similar to that of "Publication" in that it has a block of attributes.
It is different, however, in that it does not have an object key definition. Rather, it has a reference
key which indicates how the table containing the Magazine information can be joined to the table
containing the Publication information. If the Magazine tries to define an object key, an error will
be thrown.
model tutorial.magazine;
// we do not have to import the tutorial model because both object types
// are in the same model. However, we show the import statement here as
// an example.
import tutorial.*;
object type Magazine extends Publication {
// we need to specify the size of the String attribute so we know
// whether it is actually a String or if it is really a Clob
String issueNumber = magazines.issue_number VARCHAR(30);
// notice that because it extends Publication, there is not an
// explicitly "object key" declaration. Rather, there is