4.3. Required lifecycle state transitions

Now that we’ve met the different states we can examine the transitions between them. These will each be illustrated with a code snippet that would effect the transition.

4.3.1. Persisting a transient instance

To persist a transient instance, pass it to the makePersistent() method of a PersistenceManager (Figure 4.1). This is essentially a request to create a new entity in the data store. Where application identity is used this request will fail if the primary key already exists in the datastore. With data store identity the entity will be persisted even if another persistent entity already exists with identical persistent field values, as the JDO identities (created by the implementation when each instance ...

Get Java™ Data Objects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.