currentTransaction.commit();
} finally { if (doCommit) { tx.commit();
private boolean runTestQuery() { Transaction tx = pm.currentTransaction(); boolean doCommit = false; if (!tx.isActive()) { tx.begin(); doCommit = true; } Query query = null; // Run a self-test query. If it doesn't work, we will self-disable. What a PITA... String selfTestQuery = "select \"DB_ID\" from " + DBS + ""; try { prepareTxn(); query = pm.newQuery("javax.jdo.query.SQL", selfTestQuery); query.execute(); return true; } catch (Throwable t) { doCommit = false; LOG.warn("Self-test query [" + selfTestQuery + "] failed; direct SQL is disabled", t); tx.rollback(); return false; } finally { if (doCommit) { tx.commit(); } if (query != null) { query.closeAll(); } } }
public void endTransaction() { final javax.jdo.Transaction transaction = persistenceManager.currentTransaction(); if (transaction.isActive()) { transaction.commit(); } }
public void commitTransaction(PersistenceManager pm) { Transaction currentTransaction = pm.currentTransaction(); try { Preconditions.checkState(currentTransaction.isActive(), "Transaction is not active"); currentTransaction.commit(); } finally { pm.close(); } }
@Override public void commitTransaction() { if (manager.currentTransaction().isActive()) { manager.currentTransaction().commit(); } // if } // commitTransaction()
@Override public void rollbackTransaction() { if (manager.currentTransaction().isActive()) { manager.currentTransaction().commit(); } // if } // rollbackTransaction()
private void commitTransaction(PersistenceManager pm) { Transaction currentTransaction = pm.currentTransaction(); try { Preconditions.checkState(currentTransaction.isActive(), "Transaction is not active"); currentTransaction.commit(); } finally { pm.close(); } }
private void commitTransaction(PersistenceManager pm) { Transaction currentTransaction = pm.currentTransaction(); try { Preconditions.checkState(currentTransaction.isActive(), "Transaction is not active"); currentTransaction.commit(); } finally { pm.close(); } }
@Override public void run() { TestSuper t = (TestSuper) pm.getObjectById(oids.get(n)); n++; t.setId(t.getId()+DELTA); if (n % COMMIT_INTERVAL == 0) { pm.currentTransaction().commit(); pm.currentTransaction().begin(); } } });
private void checkResults(String queryFilter, int nRes) { pm.currentTransaction().commit(); pm.currentTransaction().begin(); Query q = pm.newQuery(TestClass.class, queryFilter); Collection<?> c = (Collection<?>) q.execute(); int n = 0; for (Object o: c) { assertNotNull(o); n++; } assertEquals(nRes, n); }
@Test public void testSchemaCreationWithNullArray() { PersistenceManager pm = TestTools.openPM(props); pm.currentTransaction().begin(); TestClassWithArray t = new TestClassWithArray(); t.array = null; pm.makePersistent(t); pm.currentTransaction().commit(); TestTools.closePM(); }
@Test public void testActivationOutsideTx2() { PersistenceManager pm = TestTools.openPM(); pm.currentTransaction().begin(); pm.currentTransaction().commit(); pm.close(); TestClass tc = new TestClass(); tc.setInt(5); tc.getInt(); }
@Test public void testThatPrintingDoesntThrowExceptions() { pm.currentTransaction().commit(); pm.currentTransaction().begin(); ZooClassDef def = getDef(TestClass.class); QueryParserV3 qp = new QueryParserV3( "(_int > 1 && _int < 52) || _int > 50", def, null, null, 0, Long.MAX_VALUE); QueryTreeNode qtn = qp.parseQuery(); assertNotNull(qtn.print()); }
@Test public void testThatPrintingDoesntThrowExceptions() { pm.currentTransaction().commit(); pm.currentTransaction().begin(); ZooClassDef def = getDef(TestClass.class); QueryParser qp = new QueryParser("(_int > 1 && _int < 52) || _int > 50", def, null, null); QueryTreeNode qtn = qp.parseQuery(); assertNotNull(qtn.print()); } }
@Test public void testQueryStatsWithData() { PersistenceManager pm = TestTools.openPM(); pm.currentTransaction().begin(); TestClass tc = new TestClass(); pm.makePersistent(tc); pm.currentTransaction().commit(); TestTools.closePM(); runQueries(false); }
@Test public void testSchemaCreationHierarchy() { PersistenceManager pm = TestTools.openPM(props); pm.currentTransaction().begin(); pm.makePersistent(new TestClassTiny()); pm.makePersistent(new TestClassTiny2()); pm.currentTransaction().commit(); TestTools.closePM(); }
@After public void afterTest() { TestTools.closePM(); PersistenceManager pm = TestTools.openPM(); pm.currentTransaction().begin(); pm.newQuery(TestClassTiny2.class).deletePersistentAll(); pm.newQuery(TestClassTiny.class).deletePersistentAll(); pm.currentTransaction().commit(); TestTools.closePM(); }
@Before public void before() { TestTools.createDb(); TestTools.closePM(); pm = TestTools.openPM(); pm.currentTransaction().begin(); ZooJdoHelper.schema(pm).addClass(TestClassTiny.class); ZooJdoHelper.schema(pm).addClass(TestClassTiny2.class); pm.currentTransaction().commit(); pm.currentTransaction().begin(); }
@Before public void beforeTest() { PersistenceManager pm = TestTools.openPM(); pm.currentTransaction().begin(); pm.newQuery(pm.getExtent(TestClass.class)).deletePersistentAll(); pm.newQuery(pm.getExtent(TestClassTiny.class)).deletePersistentAll(); pm.newQuery(pm.getExtent(TestClassTiny2.class)).deletePersistentAll(); pm.currentTransaction().commit(); TestTools.closePM(); }