Hi

We are using orientDB in a webapp that uses a REST api combined with 
Orients Java Object api.
We will almost exclusively only need transaction when updating an object 
but currently we do not 
track the version in REST api. The latest update call for a certain object 
is thus considered the latest version.
The problem is that an update to one object might affect another, thus we 
need transactions, preferably optimistic ones.

We don't entirely understand the documentation but our basic approach have 
been:

for (int i = 0; i < TRANSACTION_RETRY_COUNT; i++) {
    try {
        db.getTransaction().begin();
        doStuff(userUpdatedObject); 
        tempObject = db.save(userUpdatedObject);
        db.getTransaction().commit();
        userUpdatedObject= tempObject ;
        break;
    } catch (OConcurrentModificationException e) {
        if (i == TRANSACTION_RETRY_COUNT - 1) {
            throw e;
        }
    }
}

That is, the userUpdatedObject is not tracked  by the db. It comes from the 
REST api and doesn't have any version.

   - When is the OConcurrentModificationException? I am assuming in the 
   commit function?
   - We get a OConcurrentModificationException. We catch the exception and 
   retry, how does the begin() function know that the previous transaction was 
   aborted and it should start a new one and not a nested transaction?
      - Do we need to do a rollback after we caught the 
      OConcurrentModificationException? Or is that already done when the 
      exception is thrown? Basically, when do we need to manually rollback?
      - What would happen if, for example, doStuff() throw another type of 
      exception, AnotherException, that we also catch. Will it be a nested 
      transaction then? 
         - If so, do we need to do a rollback after we catch 
         AnotherException?
      - What is the difference between db.getTransaction().begin() and 
   db.begin()? With the later one I can choose transaction strategy (except 
   only optimistic is supported). Which one should we be using?
   
Overall, is this the correct approach or how should one go about it? Thanks 
for all the help!




-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to