User's Manual

Chapter 9. Persistence Tutorial 101
2.9. How do I retrieve a DataQuery, DataCollection, or DataAssociation in the order
I want (e.g., there is a sort_order link attribute that I want to sort by)?
To do this, use the setOrder() method. For further information, see Section 9.5.2 Ordering.
2.10. What is the OID class used for?
The OID class encapsulates the details of the primary key of an object. You use instances of
OID for retrieving an object from the database and you set the OID to a known value. You can
also get an OID object from a DataObject.
2.11. I would like to retrieve all instances of a particular object type (e.g.,
com.arsdigita.kernel.User). How do I do this?
You will want to use the method in the class com.arsdigita.persistence.Session
(http://rhea.redhat.com/doc/waf/6.0/api/com/arsdigita/persistence/Session.html) that retrieves
a DataCollection for all instances of a data object type. The DataCollection can be
filtered to narrow the results. It is possible to request individual properties of the collection
without instantiating an object. You can also instantiate the data object, and if you use the
DomainObjectFactory, you can get a DomainObject from the data object. It is recom-
mended, however, that you do not instantiate the object unless absolutely necessary, because
creating the object consumes extra memory resources as compared to iterating through the
DomainCollection.
As a specific example, to get all users in the system, you can execute the following line:
DataCollection authors =
SessionManager.getSession().retrieve("com.arsdigita.kernel.User");
For more information, see Section 9.2.5 Creating and Retrieving Objects in Java.