State Transitions

An instance transitions from one lifecycle state to another as the application or JDO implementation performs various operations on it. These state transitions occur during a transaction and at the completion of a transaction. A transition can occur as a result of the passing of an instance as a parameter to a method, such as makePersistent( ). An instance can also transition from one state to another without the application performing any direct operations on the instance. For example, an instance made persistent via reachability changes state without the application directly passing the instance to a method. An instance in the hollow or persistent-clean state will transition to persistent-dirty if it contains a collection field and you add or remove an element from the collection.

State Transitions During a Datastore Transaction

Figure 11-1 illustrates the state transitions that occur when you make a call to makePersistent( ) or deletePersistent( ), or when you access a managed field. In the figure, Start State 1 represents the application calling a constructor to create an instance, and Start State 2 occurs when the JDO implementation calls the no-arg constructor to instantiate an instance from the datastore.

Lifecycle-state transitions

Figure 11-1. Lifecycle-state transitions

If any persistent field of a hollow instance other than a primary-key field is read, the instance transitions ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.