[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = true)]
public sealed class OptimisticLockingAttribute :
<AttributeUsage(AttributeTargets.Class Or AttributeTargets.Interface, Inherited:=True)>
Public NotInheritable Class OptimisticLockingAttribute
The OptimisticLockingAttribute attribute specifies whether a session can lock a persistent object's state (allows optimistic locking to be enabled). To control object locking for objects that have the object locking option enabled, a new system field called by default OptimisticLockField is added to the object table's structure during the database schema update.
In optimistic concurrency, locks are set and held only while the data store is being accessed. The locks prevent other users from attempting to update objects at the same time. When an update is attempted, the original version of a changed object is compared against the existing object in the data store. If the two are different, the update fails with a concurrency error. It is up to you at that point to reconcile the two objects using your business logic.