docs: private void upgradeLockIfNeeded()
      {
          // using clone to avoid ConcurentModificationException
          Iterator iter = ((List) mvOrderOfIds.clone()).iterator();
          TransactionImpl tx = getTransaction();
          ObjectEnvelope mod;
          while(iter.hasNext())
          {
              mod = (ObjectEnvelope) mhtObjectEnvelopes.get(iter.next());
              // ignore transient objects
              if(!mod.getModificationState().isTransient())
              {
                  /*
                  now we check if all modified objects has a write lock. On insert of new
                  objects we don't need a write lock.
                  */
                  if(!mod.needsInsert())
                  {
                      if((mod.needsDelete() || mod.needsUpdate()
                              || mod.hasChanged(tx.getBroker())))
                      {
                          needsCommit = true;
                          // mark object dirty
                          mod.setModificationState(mod.getModificationState().markDirty());
                          ClassDescriptor cld = mod.getClassDescriptor();
                          // if the object isn't already locked, we will do it now
                          if(!mod.isWriteLocked())
                          {
                              tx.doSingleLock(cld, mod.getObject(), mod.getIdentity(), Transaction.WRITE);
                          }
                      }
                  }
                  else
                  {
                      needsCommit = true;
                  }
              }
          }
      }