JDO instances may be persistent or transient. When an instance is first instantiated via the new operator it is transient.
BusinessPartner bp = new BusinessPartner();
Such objects are no different to instances of the un-enhanced Java class (except in so far as they can have their state interrogated via the JDOHelper class; I’ll discuss how in Chapter 6). Transient instances require no supporting persistence infrastructure. By this I mean that a PersistenceManager instance does not have to be present, although the JDO interfaces must be available through the CLASSPATH. Furthermore they can be serialized and the serialized form de-serialized into an instance of the un-enhanced class (possibly in a different JVM).
Transient objects do not directly reflect the data in the data store and are not ordinarily subject to JDO transactions. Changes made to transient objects will not be reflected in the data store unless the object is subsequently made persistent (or unless this object is part of the closure of objects referenced – at commit time – through the persistent fields of another instance which is made persistent; so-called persistence by reachability). Transient objects live only as long as they remain referenced within the JVM and the JVM continues running. If the last reference to a transient instance is discarded, through going out of scope or being set to an alternative value, the instance will be eligible for garbage collection. When the JVM is shut down, any remaining transient objects will be destroyed.
Persistent instances represent persistent data that logically exists in a data store. They have an inherent dependence upon the underlying JDO persistence infrastructure and hold a reference to a local (same JVM) PersistenceManager instance. Changes made to persistent instances will be reflected in the data store, unless subject to transactional rollback.
Upon serialization, a persistent instance (which directly represents data in a data store) is made transient. The data still exists in the data store, but the now transient instance no longer directly represents that data. Changes subsequently made to the instance will not be reflected in the data store.