If I have a large number of objects to delete and then add to a PersistenceManager is it more efficient to do everything in one transaction or two? Currently my code looks like this:
PersistenceManager pm = m_pmFactory.getPersistenceManager(); try { pm.currentTransaction().begin(); pm.deletePersistentAll(toDelete); pm.makePersistentAll(toAdd); pm.currentTransaction().end(); } finally { if(pm.currentTransaction().isActive()) { pm.currentTransaction().rollback(); } if(!pm.isClosed()) { pm.close(); } }
Should I separate the deletes and adds into separate transactions? I think I remember reading in another forum post that you recommended this, I just wanted to clarify.