First- and Second-Class Objects
JDO provides a natural mapping of your object model to an underlying datastore using different architectures. Most of the differences between datastores are handled for you automatically. In JDO, you identify the classes of your object model that should be stored in the datastore. Instances of these classes are stored with unique identifiers and can be queried efficiently using the values of their fields. Relationships between instances are modeled as references or collections.
In Java, your application classes, such as
Role, and system-defined classes, such as
java.lang.Integer, are not treated
differently. They are all referenceable objects in memory. However,
there is a fundamental difference between these objects from the
standpoint of JDO and most datastores.
The instances of your persistent classes that you would like to be
referenced by two or more instances in the datastore are called
first-class objects (FCOs). They each have a unique identity in the
datastore, they can be queried, and they can be deleted under
application control. In addition, the JDO runtime environment guarantees
that only a single instance of an FCO with a durable identity is
instantiated in memory for a given
JDO also supports second-class objects (SCOs), which represent values. They do not represent entities that you would want to reference in the datastore. A second-class object is associated and stored as part ...