Kinds of Classes and Instances
First, we must define some terms and provide some distinctions that are essential for understanding JDO. The term “object” often refers to either a class or an instance of a class, which can be confusing sometimes. Therefore, we will use the terms “instance” and “class” instead of “object,” because it will be essential for you to understand which we are discussing.
Kinds of Classes
When using JDO, every class falls into one of the following two categories:
- Persistent class
A persistent class can have its instances stored in the datastore. To be persistent, a class must be specified in a metadata file and enhanced. The JDO specification refers to these as persistence-capable classes.
- Transient class
A transient class cannot have its instances stored in the datastore. Transient classes are not listed in a metadata file.
Furthermore, classes can be distinguished by their use of the JDO API:
- JDO-aware class
A JDO-aware class makes direct use of the JDO API. For example, it can perform a JDO query to retrieve instances from the datastore, or make specific instances persistent.
- JDO-transparent class
A JDO-transparent class does not make direct use of the JDO API.
Whether a class is JDO-aware or JDO-transparent is unrelated to
whether it is persistent. For example, the persistent classes Movie, Actor, and Role that we introduced in Chapter 1 are JDO-transparent,
because they never made an explicit call to the JDO API. On the other
hand, the MediaManiaApp class is JDO-aware, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access