DataObjects (Cayenne persistent objects) are composed of attributes and relationships. Attributes are the simplest object properties (as in "java bean properties") that can be stored in the columns in the database. Those are usually string, numeric, binary or date values. Another type of properties is relationships. They represent related DataObjects (to-one relationships) or collections of DataObjects (to-many relationships). To read and modify attributes and relationships, application code would simply invoke corresponding get or set methods. In case of to-many relationships represented by collections there are also add and remove methods.

Queries discussed in the previous chapter are used to obtain the initial sets of DataObjects. After that a graph of persistent objects is navigated and modified via relationship methods, thus hiding the underlying relational storage complexity and giving application a nice object view of the relevant subset of the database data.

Examples of working with attributes and relationships are given later in this chapter.


  1. Relationships
  2. Flattened Relationships
  3. DataObjects Example
  4. Accessing PK and FK values
  5. DataObjectUtils
  6. DataObject Validation
  7. Handling Inheritance
  8. Deleting Objects
  9. Generic Persistent Class