Menu

Optimistic Concurrency

Simon
2006-09-13
2013-04-22
  • Simon

    Simon - 2006-09-13

    Is there any sample or instructions on how to use the optimistic concurrency features?

    Thanks.

     
    • Richard Beauchamp

      Hi Simon,

      Take a look at the DomainObjects unit test OptimisticConcurrencyTests.VersionLock(). This tests against the class 'LockedByVersion' that has a column used by DomainObjects for optimistic concurrency checking. Here is the ClassDescriptor for the class:

          <ClassDescriptor ClassName="DomainObjects.Test.Domain.LockedByVersion" TableName="LOCKED_BY_VERSION" Editability="Editable" IsAbstract="false" >
              <PrimaryKeyDescriptor IsAutoIncremented="true">
                  <FieldDescriptor Id="LOCKED_BY_VERSION1" FieldName="_primaryKey" ColumnName="ID" DbType="Int32" IsDeclaredInBaseClass="true"/>
              </PrimaryKeyDescriptor>
              <FieldDescriptor Id="LOCKED_BY_VERSION2" FieldName="_value" PropertyName="Value" ColumnName="VALUE" DbType="AnsiString"/>
              <FieldDescriptor Id="LOCKED_BY_VERSION3" FieldName="_versionNumber" IsDeclaredInBaseClass="true" ColumnName="VERSION_NUMBER" DbType="Int32" IsVersionNumber="true"/>
          <FieldDescriptor Id="LOCKED_BY_VERSION4" FieldName="_createdDate" ColumnName="CREATED_DATE" DbType="DateTime" IsNullable="false"/>
          </ClassDescriptor>

      You'll see that the 'VERSION_NUMBER' column has an attribute of IsVersionNumber="true".

      The definition of the class in the Repository.xml file and usage of this class in the unit test should explain.

      Hope this helps,

      Richard

       

Log in to post a comment.