Persistence of Instances
A class is persistent if it has been specified in a JDO metadata file and enhanced. An instance of a persistent class can be either transient or persistent. The JDO specification refers to a persistent class as persistence-capable to emphasize that while a class provides support for persistence, it allows instances to be transient or persistent. We just use the phrase persistent class and note that instances can be either transient or persistent. We refer to classes that are not persistent as transient classes . All instances of a transient class are transient.
All instances of transient and persistent classes that you
construct in your applications are initially transient. They become
persistent explicitly when you pass them to makePersistent( ), or
implicitly if they are referenced by a persistent instance at
transaction commit.
Explicit Persistence
You can call the following PersistenceManager method to make a
transient instance persistent explicitly:
void makePersistent(Object obj);
You must call it in the context of an active transaction, or a
JDOUserException is thrown.
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