As was seen in the JDO States guide, objects can have many different states during their lifecycle. In reality the user only sees a small subset of these. The state changes relative to the state of the transaction controlling the unit of work.
The most common thing that a system would want to do once it had persisted an object is be able to access it again outside of a persistence transaction. There are 3 ways that this can be achieved with JDO, and the selection of which one depends on what the system wants to do with the object.
As you can see from the 3 options, they all have their uses. The most useful is the second, because it retains the linkage to the original object and so the propagation of changes into the datastore is automatic when re-attaching. That said, there are situations where you may favour the first or third. It's important to understand the consequences of your choices. |