This is a migrated thread and some comments may be shown as answers.

Unsupported Operation: explicit locking in optimistic transactions

5 Answers 70 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Arun
Top achievements
Rank 1
Arun asked on 10 Sep 2012, 10:18 AM

Dear Folks,

I am getting the error "Unsupported Operation: explicit locking in optimistic transactions" when i am trying to execute the statement 

dbContext.Scope.Transaction.Lock(gdnItems, Telerik.OpenAccess.LockMode.READ);

Please find backend configurationsettings as below.

    <BackendConfigurationSettings>
      <BackendConfiguration>
        <Backend>oracle</Backend>
        <ProviderName>Oracle.DataAccess.Client</ProviderName>
        <Runtime>
          <Concurrency>PESSIMISTIC_EXPLICIT</Concurrency>
        </Runtime>
        <ConnectionPool>
          <IsolationLevel>Serializable</IsolationLevel>
        </ConnectionPool>
        <Logging>
          <MetricStoreSnapshotInterval>0</MetricStoreSnapshotInterval>
        </Logging>
      </BackendConfiguration>

The basic idea is i want to read/write lock certain rows in table manually.

Can anyone help me out the fix this problem. 

Thanks,
Arun

5 Answers, 1 is accepted

Sort by
0
Ralph Waldenmaier
Telerik team
answered on 13 Sep 2012, 08:20 AM
Hi Arun,

I was able to reproduce the behavior you reported. This is a bug in the product, when working with the context. In order to achieve the scenario, you need to use the "old" scope approach.
Please see this link as a starting point for implementing this. 
The reason is that the concurrency control setting provided in the BackendBonfiguration is not taken into account. Also you can not specify the TransactionProperties on a scope that is obtained from a context, because there you have already a running transaction that was created implicitly by the context.
I will add this to our backlog to have this addressed soon.

Please accept my apologies for the inconvenience caused so far and thank you for pointing this out.
Feel free to ask if you have any other question.

Regards,
Ralph
the Telerik team
Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
0
Arun
Top achievements
Rank 1
answered on 19 Sep 2012, 01:43 PM
Hi Telerik,

        Thanks for your update. 

        Can you please let us know when we can expect this issue to be resolved. Since it is most important feature for any enterprise software development. 

      As you suggested does switching back to old version will resolve the problem ?. Can you please guide us how to achieve the below scenario using old version. The basic idea is we want to read/write lock certain rows in table manually. 

  Regards,
    Arun
0
Ralph Waldenmaier
Telerik team
answered on 21 Sep 2012, 08:08 AM
Hi Arun,

Attached you can find a sample solution that is using the "old" scope approach to fulfill your requirements. 
See also the following example script.

class Program
{
    static void Main(string[] args)
    {           
        using (var scope = ObjectScopeProvider1.GetNewObjectScope())
        {
            scope.TransactionProperties.Concurrency = TransactionMode.PESSIMISTIC_EXPLICIT;
            scope.Transaction.Begin();
            var prods = scope.Extent<Product>().Where(x => x.Id == 1).Single();
            scope.Transaction.Lock(prods, Telerik.OpenAccess.LockMode.WRITE);
            scope.Transaction.Commit();
        }
    }
}
The result of the locking call is the following call to the database.
SELECT "Price" COL1, "ProductName" COL2, "storeDate" COL3 FROM "Products" WHERE "ID" = :p0                                        FOR UPDATE [:p0=1]

You can switch back to the "old" classic OpenAccess as described here.
Unfortunately, I can not give you an exact timeframe on when this is fixed for the context approach.
I will keep you updated on this.

Hope that helps.
Do come back if you have any other question.
All the best,
Ralph
the Telerik team
Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
0
Omar
Top achievements
Rank 1
answered on 28 Apr 2014, 09:42 AM
should i write begin and commit in lock ??
0
Jan Blessenohl
Telerik team
answered on 30 Apr 2014, 03:28 PM
Hello,

as long as you use the scope exclusive it is not nessesary to suround it with a lock. 

Regards,
Jan Blessenohl
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
General Discussions
Asked by
Arun
Top achievements
Rank 1
Answers by
Ralph Waldenmaier
Telerik team
Arun
Top achievements
Rank 1
Omar
Top achievements
Rank 1
Jan Blessenohl
Telerik team
Share this question
or