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

Telerik.OpenAccess.Exceptions.OptimisticVerificationException: Row not found

1 Answer 698 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Eric
Top achievements
Rank 1
Eric asked on 11 Feb 2016, 01:10 PM

Hi,

Telerik OpenAccess throws an error when attempt to update my SQL Table: 

Telerik.OpenAccess.Exceptions.OptimisticVerificationException: Row not found: GenericOID@e5e5eae8 License Id=3
UPDATE [users_Licenses] SET [ExpiresOn] = ? WHERE [Id] = ? AND [ExpiresOn] = ?
Params: [@p0=2016-05-11T12:21:37.3083016+02:00 @p1=3 @p2=2016-05-11T12:21:37.2930000]
   at OpenAccessRuntime.ExceptionWrapper.Throw()
   at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.handleException(Exception x, Boolean needsRollback)
   at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.internalCommit(Boolean phase)
   at OpenAccessRuntime.DataObjects.OpenAccessPersistenceManagerImp.commit()
   at LOreal.Mynews.OpenAccess.Services.LicenseService.Update(License instance)
   at LOreal.Mynews.Mobile.WebApi.Helpers.Security.LOrealAuthenticationInspector.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)

 

I don't understand why OpenAccess create where clause with filter on [ExpiresOn].

[ExpiresOn] is not an identity field, ([Id] is)

SQL query should be

 UPDATE [users_Licenses] SET [ExpiresOn] = ? WHERE [Id] = ?

 

can some one help me ?

 

thanks in advance

 Eric

1 Answer, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 16 Feb 2016, 01:59 PM
Hi Eric,

 What you see is an OptimisticVerificationException. As the name suggests DataAccess performs certain checks before committing changes to ensure that the object is not changed by some other context/application in the meantime.  There are various Optimistic concurrency modes - 'Changed' is one of them.

In this mode DataAccess checks all the fields that are modified (in your case 'ExpiresOn' field) with their original value that existed when the object was read. Hence you see the 'ExpiresOn =?' filter. By performing this check we can ensure that the object was not changed in the meantime and that you are not overwriting the change with your change. 
You can turn off optimistic concurrency checks or select another mode where you can use an explicit optimistic concurrency column (version column) and then DataAccess will only check against this column before committing.

Do get back in case you need further assistance.

Regards,
Ady
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Tags
Data Access Free Edition
Asked by
Eric
Top achievements
Rank 1
Answers by
Ady
Telerik team
Share this question
or