Descend

ExtObjectContainer#descend method allows you to navigate from a persistent object to it's members without activating or instantiating intermediate objects.

UtilityExample.java: testDescend
01private static void testDescend() { 02 storeSensorPanel(); 03 Configuration configuration = Db4o.newConfiguration(); 04 configuration.activationDepth(1); 05 ObjectContainer container = Db4o.openFile(configuration, DB4O_FILE_NAME); 06 try { 07 System.out 08 .println("Object container activation depth = 1"); 09 ObjectSet result = container.get(new SensorPanel(1)); 10 SensorPanel spParent = (SensorPanel) result.get(0); 11 SensorPanel spDescend = (SensorPanel) container.ext() 12 .descend( 13 (Object) spParent, 14 new String[] { "next", "next", "next", 15 "next", "next" }); 16 container.ext().activate(spDescend, 5); 17 System.out.println(spDescend); 18 } finally { 19 container.close(); 20 } 21 }

[/filter]

[filter=cs]

UtilityExample.cs: TestDescend
01public static void TestDescend() 02 { 03 StoreSensorPanel(); 04 IConfiguration configuration = Db4oFactory.NewConfiguration(); 05 configuration.ActivationDepth(1); 06 IObjectContainer db = Db4oFactory.OpenFile(configuration, Db4oFileName); 07 try 08 { 09 System.Console.WriteLine("Object container activation depth = 1"); 10 IObjectSet result = db.Get(new SensorPanel(1)); 11 SensorPanel spParent = (SensorPanel)result[0]; 12 SensorPanel spDescend = (SensorPanel)db.Ext().Descend((Object)spParent, new String[]{"_next","_next","_next","_next","_next"}); 13 db.Ext().Activate(spDescend, 5); 14 System.Console.WriteLine(spDescend); 15 } 16 finally 17 { 18 db.Close(); 19 } 20 }

Navigating in this way can save you resources on activating only the objects you really need.