Name

Version Number Pattern

Goal

Provide a simple way to detect when an object has changed (Figure B-21).

Versioned object
Figure B-21. Versioned object

Participants

Versioned object

Provides an object representation of data subject to change control, and tracks the changes that occur to the data.

Business tier code

Uses the version number to determine when to persist the versioned object.

Interactions

When an application modifies a property on a versioned object, a version number associated with the object is incremented. Other code can record this version number and use the information to resolve concurrency problems, such as change detection in an optimistic concurrency implementation.

Notes

See related patterns IsDirty and Optimistic Concurrency.

Get J2EE Design Patterns 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.