Provides an easy way to use optimistic/pessimistic locking.