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

VOA keygen table issue

3 Answers 123 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gopinath
Top achievements
Rank 1
Gopinath asked on 25 Feb 2013, 09:32 AM
Hello,

I use ORM 2011.2.713
I have table in oracle which is created and populated with some rows through oracle scripts. Later some rows are deleted using different scripts.
I have also set this key in my application.

  

key="db-key-generator" value="HIGHLOW"

 

for this class using reverse mapping.

Now when i try to insert rows through the application, i get an error. Its because the id which is in keygen table could have been deleted using the oracle script.

Please let me know how to fix this issue. When a row will be generated in this table. Is there a way I can use some kind of refresh for this table before I Use it from the application.

Thanks,
Gopi

3 Answers, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 27 Feb 2013, 04:07 PM
Hi Gopinath,

 This table is initialized when you obtain the first instance of IObjectScope. At this time the metadata for the entire persistent model is calculated and if there is no entry in the voa_keygen for a particular class then a row is added by obtaining the max value from the persistent table. In short, this table is initialized when you try to use the scope for the first time.

 What is the exact exception you get? Do you delete rows from this table in parallel to your OpenAccess application ? You should not delete rows from this table after it has been initialized.

Regards,
Ady
the Telerik team
OpenAccess ORM Q1 2013 is out featuring Multi-Diagrams, Persistent Data Stream Support and much more. Sign up for a free webinar to see all the new stuff in action.
0
Gopinath
Top achievements
Rank 1
answered on 28 Feb 2013, 12:18 PM
hello Ady,

I am not deleting any rows from the keygen table.
The table is created by a database scripts and not by the application.
Now, the records for this table can be created either by an application and also through an database script. When I insert a record through db script, the keygen value is not updated. So when application tries to insert a new record, it trys to insert a record with primary key which already exists(might be inserted by db script).

I hope you now got the scenario. I assume the keygen table should be updated with last_id whenever a record is inserted by db scripts. Please advice if you see anyother way to fix this issue.

Thanks,
Gopi
0
Ady
Telerik team
answered on 01 Mar 2013, 04:38 PM
Hi Gopi,

 Let me explain how the key generator mechanism (called HIGHLOW) with the voa_keygen table works.

  1.  When the metadata is calculated (when you obtain an instance of IObjectScope) keygenerator for each class is initialized. To do this the table which has rows for this class is queried and the max id is obtained and the voa_keygen table is updated. 
  2. Whenever a new instance (row) is to be inserted for a class, OpenAccess uses the next higher value. Obviously the voa_keygen table has to be updated with last used id. 
  3. To avoid having to do this for each id required, OpenAccess 'grabs' a fixed amount of ids at once. The default is 10. So the voa_keygen is updated with existingvalue + 10. Once 10 keys are used up the voa_keygen table is again updated by incrementing the existing value by 10

 Now if a script has inserted rows into the table (It should insert values higher than  what is present in the voa_keygen table) it would need to update the voa_keygen table with the next available id that can be used by OpenAccess. OpenAccess would then grab the next 10 and update the table. You can change this default grab size to a lower value but this would mean additional server calls for each new id.

Do get back in case you need further assistance.

Kind regards,
Ady
the Telerik team
OpenAccess ORM Q1 2013 is out featuring Multi-Diagrams, Persistent Data Stream Support and much more. Sign up for a free webinar to see all the new stuff in action.
Tags
Development (API, general questions)
Asked by
Gopinath
Top achievements
Rank 1
Answers by
Ady
Telerik team
Gopinath
Top achievements
Rank 1
Share this question
or