/** * Check whether the ObjectStore is performing a transaction, delegate to internal * ObjectStoreWriter. * * @return true if in a transaction, false otherwise * @throws ObjectStoreException if an error occurs the check */ public boolean isInTransaction() throws ObjectStoreException { return osw.isInTransaction(); }
/** * Check whether the ObjectStore is performing a transaction, delegate to internal * ObjectStoreWriter. * * @return true if in a transaction, false otherwise * @throws ObjectStoreException if an error occurs the check */ public boolean isInTransaction() throws ObjectStoreException { return osw.isInTransaction(); }
/** * {@inheritDoc} */ public void close() throws ObjectStoreException { if (osw.isInTransaction()) { osw.commitTransaction(); } }
/** * {@inheritDoc} */ public void close() throws ObjectStoreException { if (osw.isInTransaction()) { osw.commitTransaction(); } }
@Test public void testExceptionOutOfTransaction() throws Exception { Assert.assertFalse(writer.isInTransaction()); // First, cause an exception outside a transaction try { writer.store(new RuntimeExceptionEmployee()); } catch (Exception e) {} Assert.assertFalse(writer.isInTransaction()); // Now try and do something normal. writer.getObjectById(new Integer(2)); } }
@Test public void testExceptionOutOfTransaction() throws Exception { Assert.assertFalse(writer.isInTransaction()); // First, cause an exception outside a transaction try { writer.store(new RuntimeExceptionEmployee()); } catch (Exception e) {} Assert.assertFalse(writer.isInTransaction()); // Now try and do something normal. writer.getObjectById(new Integer(2)); } }
@Test public void testExceptionOutOfTransaction() throws Exception { Assert.assertFalse(writer.isInTransaction()); // First, cause an exception outside a transaction try { writer.store(new RuntimeExceptionEmployee()); } catch (Exception e) {} Assert.assertFalse(writer.isInTransaction()); // Now try and do something normal. writer.getObjectById(new Integer(2)); } }
if (osw != null) { try { if (osw.isInTransaction()) { osw.abortTransaction();
if (osw != null) { try { if (osw.isInTransaction()) { osw.abortTransaction();
} finally { if (osw != null) { if (osw.isInTransaction()) { osw.abortTransaction();
public void tearDown() throws Exception { System.out.println("in tear down"); ObjectStoreWriter osw = ObjectStoreWriterFactory.getObjectStoreWriter("osw.unittest"); if (osw.isInTransaction()) { osw.abortTransaction(); } Query q = new Query(); QueryClass qc = new QueryClass(InterMineObject.class); q.addFrom(qc); q.addToSelect(qc); SingletonResults res = osw.getObjectStore().executeSingleton(q); System.out.println("created results"); Iterator resIter = res.iterator(); osw.beginTransaction(); while (resIter.hasNext()) { InterMineObject o = (InterMineObject) resIter.next(); System.out.println("deleting: " + o.getId()); osw.delete(o); } osw.commitTransaction(); System.out.println("committed transaction"); osw.close(); System.out.println("closed objectstore"); }
uosw.commitTransaction(); } catch (ObjectStoreException e) { if (uosw.isInTransaction()) { uosw.abortTransaction(); } finally { if (uosw.isInTransaction()) { uosw.abortTransaction();
uosw.commitTransaction(); } catch (ObjectStoreException e) { if (uosw.isInTransaction()) { uosw.abortTransaction(); } finally { if (uosw.isInTransaction()) { uosw.abortTransaction();
@Test public void testWriteBatchingAndGetObject() throws Exception { Address address1 = new Address(); address1.setAddress("Address 1"); writer.flushObjectById(); os.flushObjectById(); try { writer.beginTransaction(); writer.store(address1); Assert.assertNotNull(writer.getObjectById(address1.getId(), Address.class)); } finally { if (writer.isInTransaction()) { writer.abortTransaction(); } } }
private void cleanUserProfile() throws ObjectStoreException { if (userProfileOSW.isInTransaction()) { userProfileOSW.abortTransaction(); } Query q = new Query(); QueryClass qc = new QueryClass(Tag.class); q.addFrom(qc); q.addToSelect(qc); q.setConstraint(new SimpleConstraint(new QueryField(qc, "tagName"), ConstraintOp.MATCHES, new QueryValue("test%"))); SingletonResults res = userProfileOS.executeSingleton(q); Iterator resIter = res.iterator(); userProfileOSW.beginTransaction(); while (resIter.hasNext()) { InterMineObject o = (InterMineObject) resIter.next(); userProfileOSW.delete(o); } removeUserProfile("bob"); removeUserProfile("sally"); userProfileOSW.commitTransaction(); userProfileOSW.close(); }
} finally { if (osw != null) { if (osw.isInTransaction()) { osw.abortTransaction();
} finally { if (osw != null) { if (osw.isInTransaction()) { osw.abortTransaction();
} finally { if (osw != null) { if (osw.isInTransaction()) { osw.abortTransaction();
Assert.assertTrue(writer.isInTransaction()); Assert.assertFalse(writer.isInTransaction()); res = os.execute(q); Assert.assertEquals(2, res.size());
Assert.assertTrue(writer.isInTransaction()); Assert.assertFalse(writer.isInTransaction());