How to wait for a Transaction ends in JDO?

91 views Asked by At

I encounter a issue that in the worst case only happens. Ex. I have a Job that runs every minute

    UpdateJobForAnObjectA:
    PersistenceManager pm = Context.getPersistenceManager();
    Transaction tx = pm.currentTransaction();
    tx.begin();
    update a collection of an ObjectA
    tx.comit();
    pm.close();

Now I have a deadlock(Pessimist Strategy) or an opstimic lock violation(Optimistic Violation) if in another segment I update an objectA. I set to nonTransactionalRead and nonTransacionalWriete and still I'm having the error of deadlock or opstimic lock violation. But there is a way that see if I can wait for a transaction ends? Using JDO and KODO

1

There are 1 answers

0
Neil Stockton On BEST ANSWER

You can set a Synchronization object on the Transaction, and use its methods to be notified when a txn commits/rolls back.