01: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
02:
03: This file is part of the db4o open source object database.
04:
05: db4o is free software; you can redistribute it and/or modify it under
06: the terms of version 2 of the GNU General Public License as published
07: by the Free Software Foundation and as clarified by db4objects' GPL
08: interpretation policy, available at
09: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11: Suite 350, San Mateo, CA 94403, USA.
12:
13: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14: WARRANTY; without even the implied warranty of MERCHANTABILITY or
15: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16: for more details.
17:
18: You should have received a copy of the GNU General Public License along
19: with this program; if not, write to the Free Software Foundation, Inc.,
20: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21: package com.db4o.test.legacy;
22:
23: import com.db4o.*;
24: import com.db4o.ext.*;
25: import com.db4o.query.*;
26: import com.db4o.test.*;
27:
28: public class MultiDelete {
29:
30: public MultiDelete child;
31: public String name;
32: public Object forLong;
33: public Long myLong;
34: public Object[] untypedArr;
35: public Long[] typedArr;
36:
37: public void configure() {
38: Db4o.configure().objectClass(this ).cascadeOnDelete(true);
39: Db4o.configure().objectClass(this ).cascadeOnUpdate(true);
40: }
41:
42: public void store() {
43: MultiDelete md = new MultiDelete();
44: md.name = "killmefirst";
45: md.setMembers();
46: md.child = new MultiDelete();
47: md.child.setMembers();
48: Test.store(md);
49: }
50:
51: private void setMembers() {
52: forLong = new Long(100);
53: myLong = new Long(100);
54: untypedArr = new Object[] { new Long(10), "hi",
55: new MultiDelete() };
56: typedArr = new Long[] { new Long(3), new Long(7), new Long(9), };
57: }
58:
59: public void test() {
60: Query q = Test.query();
61: q.constrain(MultiDelete.class);
62: q.descend("name").constrain("killmefirst");
63: ObjectSet objectSet = q.execute();
64: Test.ensureEquals(1, objectSet.size());
65: MultiDelete md = (MultiDelete) objectSet.next();
66: ExtObjectContainer oc = Test.objectContainer();
67: long id = oc.getID(md);
68: oc.delete(md);
69:
70: MultiDelete afterDelete = (MultiDelete) oc.getByID(id);
71: oc.delete(md);
72: }
73:
74: }
|