Hello,

I am using optimistic locking for a few classes/tables in my application. However, in certain circumstances when my application starts up, I want to disable optimistic locking for the lifetime of the application. I have tried to modify the repository metadata at runtime, but I still get an OptimisticLockException when trying to update an object whose locking field is not consistent with the database. I've included my disabling method below. Is there anything I can add to it to completely disable this mechanism?

private void disableOptimisticLocking() {
DescriptorRepository r = MetadataManager.getInstance().getGlobalRepository();
   Map dt = r.getDescriptorTable();
Iterator i = dt.entrySet().iterator();
   while (i.hasNext()) {
       Map.Entry entry = (Map.Entry) i.next();
       ClassDescriptor cd = (ClassDescriptor) entry.getValue();

       if (!cd.isInterface() && cd.isLocking()) {
           FieldDescriptor[] lockingFields = cd.getLockingFields();
           for (int j = 0; j < lockingFields.length; j++) {
               FieldDescriptor descriptor = lockingFields[j];
               descriptor.setLocking(false);
               descriptor.setUpdateLock(false);
           }
       }
   }
}

Thanks in advance,
Colin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to