Telerik blogs

Telerik OpenAccess ORM provides you with a mechanism to handle the Concurrency control. Concurrency control is the management of contention for data resources. It ensures that the transactions are executed following the ACID rules.

There are two concurrency control schemes: pessimistic and optimistic. A concurrency control scheme is considered pessimistic when it locks a given resource early in the data-access transaction and does not release it until the transaction is closed. A concurrency control scheme is considered optimistic when locks are acquired and released over a very short period of time at the end of a transaction.

The Telerik OpenAccess supports several modes for Concurrency control. In this blog post we will discuss how to use the ‘backend’ concurrency mode.

The backend mode uses column of datetime type to maintain the version of a row. This column is being automatically modified on every update of the row. This mechanism can be used with the MSSQL family and Oracle modes:

  • Microsoft SQL Server family - 'rowversion/timestamp’ - It uses a timestamp column to detect concurrent updates. The timestamp is set on every update and the previous value is included in the where clause;
  • Oracle – ‘ORA_ROWSCN’ - It returns, for each row, the upper bound system change number (SCN) of the most recent change to the row. This pseudo column is useful for determining approximately when a row was last updated.  Note that the SCN value is set by the Oracle server after a record has been modified;

How to set up the backend concurrency control mode depends on the data model classes. In case of an existing schema you should use the Reverse Mapping Wizard, otherwise – Forward Mapping Wizard.

Reverse Mapping Wizard:

  • The Reverse mapping wizard detects a timestamp column (for MS SQL Server) and treats that as a version column.

Forward Mapping Wizard:

  • During the Forward Mapping process locate and click on the class node;
  • On the right inside the Concurrency Control box you should set the ‘Verify by’ from the combo box.  If the class has a field with the required type (System.SByte, System.Int16, System.Int32, System.Int64) you can select this field in the ‘Field’ combo box.  If you do not have a field, select default. OpenAccess will create a timestamp column in the table and will use it for concurrency checks;

timestamp


Comments

Comments are disabled in preview mode.