Stored Value Methods
The stored value methods, storedValueForKey: and takeStoredValue:forKey: (storedValueForKey and takeStoredValueForKey in Java), are used by the framework when accessing properties of an enterprise object to get or set properties for state storage and restoration (either from the database or to an in-memory snapshot). This access is considered private to the enterprise object and is invoked by the Framework to effect persistence on the object's behalf.
void setBonus(double newBonus) {This code should be activated when the object is updated with values provided by a user through the application's user interface, but not when the bonus property is restored from the database. Since the Framework restores the property using takeStoredValue:forKey: (takeStoredValueForKey in Java) and since this method accesses the _bonus instance variable in preference to calling the accessor, the unnecessary (and possibly harmful) recomputation of _total is avoided. If the object actually wants to intervene when a property is set from the database, it has two options:
willChange();
_total += (newBonus - _bonus);
}
Table of Contents Next Section