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
01private static void checkStored() { 02 // create a linked list with length 10 03 SensorPanel list = new SensorPanel().createList(10); 04 new File(DB4O_FILE_NAME).delete(); 05 ObjectContainer container = Db4o.openFile(DB4O_FILE_NAME); 06 try { 07 // store all elements with one statement, since all 08 // elements are new 09 container.set(list); 10 Object sensor = (Object) list.sensor; 11 SensorPanel sp5 = list.next.next.next.next; 12 System.out.println("Root element " + list + " isStored: " 13 + container.ext().isStored(list)); 14 System.out.println("Simple type " + sensor 15 + " isStored: " 16 + container.ext().isStored(sensor)); 17 System.out.println("Descend element " + sp5 18 + " isStored: " + container.ext().isStored(sp5)); 19 container.delete(list); 20 System.out.println("Root element " + list + " isStored: " 21 + container.ext().isStored(list)); 22 } finally { 23 container.close(); 24 } 25 }