package com.db4o.samples;

import com.db4o.*;
import com.db4o.lib.Logger;

public class S11_Instantiation_Depth
{
	public static void main(String[] args)
	{
		ObjectContainer db = Db4o.openFile("samples.yap");
		Logger.log("*** S11 Retrieving all Company");
		

		Company company = new Company();
		ObjectSet os = db.get(company);
		// Depending on how the QBE (Query-By-Example)
		// template is constructed, you can control
		// the instantiation depth.
		
		// A "naked" company object only retrieves primitive members.
		
		
		while(os.hasNext()){
			Logger.log(db, os.next());
		}
		
		Logger.log("*** Retrieving all Company and attached Employees");
		
		
		company.employees = new Individual[0];
		os = db.get(company);
		// Now the QBE template has an attached array of Individual[0].
		// Accordingly the array of Individual will also be instantiated
		// in the result.
		
		
		while(os.hasNext()){
			Logger.log(db, os.next());
		}
		db.close();
	}
}
