1 21 package com.db4o.test; 22 23 import com.db4o.*; 24 25 public class DualDelete { 26 27 public Atom atom; 28 29 public void configure(){ 30 Db4o.configure().objectClass(this).cascadeOnDelete(true); 31 Db4o.configure().objectClass(this).cascadeOnUpdate(true); 32 } 33 34 public void store(){ 35 Test.deleteAllInstances(this); 36 Test.deleteAllInstances(new Atom()); 37 DualDelete dd1 = new DualDelete(); 38 dd1.atom = new Atom("justone"); 39 Test.store(dd1); 40 DualDelete dd2 = new DualDelete(); 41 dd2.atom = dd1.atom; 42 Test.store(dd2); 43 } 44 45 public void test(){ 46 Test.deleteAllInstances(this); 47 Test.ensureOccurrences(new Atom(), 0); 48 Test.rollBack(); 49 Test.ensureOccurrences(new Atom(), 1); 50 Test.deleteAllInstances(this); 51 Test.ensureOccurrences(new Atom(), 0); 52 Test.commit(); 53 Test.ensureOccurrences(new Atom(), 0); 54 Test.rollBack(); 55 Test.ensureOccurrences(new Atom(), 0); 56 } 57 58 59 } 60 | Popular Tags |