Restoring Values at Transaction Rollback
We have seen how an application can retain persistent field values
in cached instances across transactions by using the RetainValues property. But this property is
effective only at commit. If you want to preserve cached values even if
a transaction rolls back, you need to use the RestoreValues property. Unlike RetainValues, RestoreValues is not an optional feature, and
the property setting affects the treatment of new instances as well as
persistent-clean and persistent-dirty instances.
With RestoreValues set to
false, persistent transactional
instances have their values cleared at transaction rollback, and the
instances transition to hollow. This is shown in Figure 14-3. Subsequent reads of
fields in these instances require access to the datastore. In order to
allow accesses of the values in the instances without accessing the
datastore, the application sets the RestoreValues flag to true.

Figure 14-3. Rollback with RestoreValues true
Similar to RetainValues, there
are several ways to set the RestoreValues property:
Your application can include the
javax.jdo.option.RestoreValuesproperty with a value oftrueorfalsein thePropertiesinstance used to construct thePersistenceManagerFactory.Your application can set the property using
setRestoreValues( )inPersistenceManagerFactory.Your application can set the property using
setRestoreValues( ...
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