This is a migrated thread and some comments may be shown as answers.
db-optimistic-locking with version
1 Answer 19 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Devanand Chahal
Top achievements
Rank 2
Devanand Chahal asked on 24 Feb 2010, 06:13 AM
I am trying to use version for db-optimistic-locking. Let me clear my scenario:

I have business layer that act as the data transporter between my database and UI layer.

I have model classes which transform the data from database to contract classes (contract classes are consumed by UI- IN my case its Flex Builder). so from my scenario its clear that i am working on disconnected mode.

I have a contractClass and modelClass(Persistent class), Contract class have one more field names VersionInformation.
I bring data in model class from data base, got the version of the modelClass and attach the version to  VersionInformation field of contractClass.
string versionInformation = Telerik.OpenAccess.DataObjectKey.Obtain(modelClass);
contractClass.VersionInformation = versionInformation;
Here I what I am getting in VersionInformation is not proper,
it is giving me :
+ { path of the modelClass}:{PrimaryKey of the model class}
for example 
+{LanguageComponent.Model.MtLangauge}:{6101146}  [here MtLanguage is the persistent modelClass and 6101146 is the value of primary key for retrieved record]. 

Now I bring the contractClass to UI, and I modified the same record at UI. But in between I change the column value for same record in database or someone else updated the same record. 

Now after updating the contractClass properties values I bring the same contract to Business layer, at business layer I get the latest  record from dataBase and again generate the VersionInformation, and compared the oldVersion with the latest version that is generated based on modelClass object that is just retrieved from database for the same primary key. As someone else already updated the same record , it must give a different version to me for the same record but it is giving the same versionInformation value. because in versionInformation i got class path and primary key combination.

I also try with ora_rowscn, It works fine, but for this I have overhead of adding additional attribute in my persistentclass(modelClass) and also mapping of this attribute from contract to model class. If I will successfully use versioninformation I would save my lot of time by not adding additional attribute in my all model classes, and doing mapping for same.

Please correct me where I m wrong in my approach regarding VersionInformation.


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 26 Feb 2010, 06:22 PM
Hello Devanand Chahal,

It seems your persistent capable class does not have any of the fields set as "version". You should mark one of the field to be a version field, otherwise OpenAccess would not know where to get the version information from.
If you are using reverse mapping, go to the Reverse mapping wizard, select the version field in the treeview (advanced view) and enable the version checkbox. If you are using forward mapping, open the Forward mapping wizard, change the verify by option to version and select the appropriate field.
Afterwards you should get the version value at the beginning of the data object key string instead of the + sign that you are getting now.
Hope that helps.

All the best,
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Data Access Free Edition
Asked by
Devanand Chahal
Top achievements
Rank 2
Answers by
Telerik team
Share this question