How to retry / recover from java.sql.SQLexception: simultaneous modification

Using JDO on GAE, I use a simple database transaction transaction block, as shown below.

What is a good way to redo / restore from an abandoned java.sql.SQLException: simultaneous modification?

closed end provider pmp; ...

PersistenceManager pm = pmp.get (); try {pm.currentTransaction () starts () ;.

MyObject myObject = pm.getObjectById (MyObject.class, id);

pm.currentTransaction () commit () ;.

} finally {

if (pm.currentTransaction (). isActive ()) {log.severe (this.getClass (). getName () + "catch exception DATABASE."); pm.currentTransaction () rollback (). }}

+3
source share
1 answer

Where is this exception really thrown? Are you sure of the semantics of commit () and isActive ()? commit () can automatically create a new transaction, leaving the transaction always active.

My other assumption would be that this is a singleton bean, accessed at the same time, and they all end up in the same transaction with other requests, while modifying your requested object.

0
source

Source: https://habr.com/ru/post/1731096/


All Articles