KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > db4o > test > legacy > MultiDelete


1 /* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com
2
3 This file is part of the db4o open source object database.
4
5 db4o is free software; you can redistribute it and/or modify it under
6 the terms of version 2 of the GNU General Public License as published
7 by the Free Software Foundation and as clarified by db4objects' GPL
8 interpretation policy, available at
9 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
29 public class MultiDelete {
30     
31     public MultiDelete child;
32     public String JavaDoc name;
33     public Object JavaDoc forLong;
34     public Long JavaDoc myLong;
35     public Object JavaDoc[] untypedArr;
36     public Long JavaDoc[] typedArr;
37     
38     
39     public void configure(){
40         Db4o.configure().objectClass(this).cascadeOnDelete(true);
41         Db4o.configure().objectClass(this).cascadeOnUpdate(true);
42     }
43     
44     public void store(){
45         MultiDelete md = new MultiDelete();
46         md.name = "killmefirst";
47         md.setMembers();
48         md.child = new MultiDelete();
49         md.child.setMembers();
50         Test.store(md);
51     }
52     
53     private void setMembers(){
54         forLong = new Long JavaDoc(100);
55         myLong = new Long JavaDoc(100);
56         untypedArr = new Object JavaDoc[]{
57             new Long JavaDoc(10),
58             "hi",
59             new MultiDelete()
60         };
61         typedArr = new Long JavaDoc[]{
62             new Long JavaDoc(3),
63             new Long JavaDoc(7),
64             new Long JavaDoc(9),
65         };
66     }
67     
68     public void test(){
69         Query q = Test.query();
70         q.constrain(MultiDelete.class);
71         q.descend("name").constrain("killmefirst");
72         ObjectSet objectSet = q.execute();
73         Test.ensureEquals(1,objectSet.size());
74         MultiDelete md = (MultiDelete)objectSet.next();
75         ExtObjectContainer oc = Test.objectContainer();
76         long id = oc.getID(md);
77         oc.delete(md);
78         
79         MultiDelete afterDelete = (MultiDelete)oc.getByID(id);
80         oc.delete(md);
81     }
82     
83
84 }
85
Popular Tags