IsStored

ExtObjectContainer#isStored helps you to define if the object is stored in the database. The following example shows how to use it:

UtilityExample.java: checkStored
01public static void checkStored(){ 02 // create a linked list with length 10 03 SensorPanel list = new SensorPanel().createList(10); 04 new File(Util.YAPFILENAME).delete(); 05 ObjectContainer db = Db4o.openFile(Util.YAPFILENAME); 06 try { 07 // store all elements with one statement, since all elements are new 08 db.set(list); 09 Object sensor = (Object)list.sensor; 10 SensorPanel sp5 = list.next.next.next.next; 11 System.out.println("Root element "+list+" isStored: " + db.ext().isStored(list)); 12 System.out.println("Simple type "+sensor+" isStored: " + db.ext().isStored(sensor)); 13 System.out.println("Descend element "+sp5+" isStored: " + db.ext().isStored(sp5)); 14 db.delete(list); 15 System.out.println("Root element "+list+" isStored: " + db.ext().isStored(list)); 16 } finally { 17 db.close(); 18 } 19 }