Unsupported Operation: explicit locking in optimistic transactions

6 posts, 0 answers
  1. Arun
    Arun avatar
    3 posts
    Member since:
    Aug 2012

    Posted 10 Sep 2012 Link to this post


    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
  2. Ralph Waldenmaier
    Admin
    Ralph Waldenmaier avatar
    202 posts

    Posted 13 Sep 2012 Link to this post

    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!
  3. DevCraft banner
  4. Arun
    Arun avatar
    2 posts
    Member since:
    Aug 2012

    Posted 19 Sep 2012 Link to this post

    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
  5. Ralph Waldenmaier
    Admin
    Ralph Waldenmaier avatar
    202 posts

    Posted 21 Sep 2012 Link to this post

    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!
  6. Omar
    Omar avatar
    5 posts
    Member since:
    May 2013

    Posted 28 Apr 2014 in reply to Ralph Waldenmaier Link to this post

    should i write begin and commit in lock ??
  7. Jan Blessenohl
    Admin
    Jan Blessenohl avatar
    707 posts

    Posted 30 Apr 2014 Link to this post

    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.
     
Back to Top
DevCraft banner