/* * delete - set - commit set - commit delete */ public void testSD() { ExtObjectContainer oc1 = openNewSession(); ExtObjectContainer oc2 = openNewSession(); ExtObjectContainer oc3 = openNewSession(); try { SimpleObject o1 = (SimpleObject) retrieveOnlyInstance(oc1, SimpleObject.class); oc1.delete(o1); SimpleObject o2 = (SimpleObject) retrieveOnlyInstance(oc2, SimpleObject.class); Assert.areEqual("hello", o2.getS()); o2.setS("o2"); oc2.store(o2); oc2.commit(); oc1.commit(); assertOccurrences(oc1, SimpleObject.class, 0); assertOccurrences(oc2, SimpleObject.class, 0); assertOccurrences(oc3, SimpleObject.class, 0); } finally { oc1.close(); oc2.close(); oc3.close(); } }
/* * delete - set - commit delete - commit set */ public void _testDS() { ExtObjectContainer oc1 = openNewSession(); ExtObjectContainer oc2 = openNewSession(); ExtObjectContainer oc3 = openNewSession(); try { SimpleObject o1 = (SimpleObject) retrieveOnlyInstance(oc1, SimpleObject.class); oc1.delete(o1); SimpleObject o2 = (SimpleObject) retrieveOnlyInstance(oc2, SimpleObject.class); Assert.areEqual("hello", o2.getS()); o2.setS("o2"); oc2.store(o2); oc1.commit(); oc2.commit(); o1 = (SimpleObject) retrieveOnlyInstance(oc1, SimpleObject.class); oc1.refresh(o1, Integer.MAX_VALUE); Assert.areEqual("o2", o1.getS()); o2 = (SimpleObject) retrieveOnlyInstance(oc2, SimpleObject.class); oc2.refresh(o2, Integer.MAX_VALUE); Assert.areEqual("o2", o2.getS()); SimpleObject o3 = (SimpleObject) retrieveOnlyInstance(oc3, SimpleObject.class); oc1.refresh(o1, Integer.MAX_VALUE); Assert.areEqual("o2", o3.getS()); } finally { oc1.close(); oc2.close(); oc3.close(); } }
public void testDelete() { ExtObjectContainer oc = fixture().db(); initGenericObjects(); ReflectClass rc = getReflectClass(oc, PERSON_CLASSNAME); Assert.isNotNull(rc); Query q = oc.query(); q.constrain(rc); ObjectSet results = q.execute(); while (results.hasNext()) { Object o = results.next(); oc.delete(o); } oc.commit(); // now query to make sure there are none left q = oc.query(); q.constrain(rc); q.descend("surname").constrain("John"); results = q.execute(); Assert.isTrue(results.size() == 0); }
public void concDelete(ExtObjectContainer oc) throws Exception { int size = countOccurences(oc, SimpleObject.class); if (size == 0) { // already deleted return; } Assert.areEqual(ELEMENT_COUNT, size); ObjectSet os = oc.query(ArrayItem.class); if (os.size() == 0) { // already deteled return; } Assert.areEqual(1, os.size()); ArrayItem item = (ArrayItem) os.next(); // waits for other threads Thread.sleep(500); oc.delete(item); oc.commit(); assertOccurrences(oc, SimpleObject.class, 0); }