package com.db4o.samples;

import com.db4o.*;
import com.db4o.lib.Logger;

public class S09_Update
{
	public static void main(String[] args)
	{
		ObjectContainer db = Db4o.openFile("samples.yap");
		Logger.log("*** S09 Updating all Individual where firstName is 'Alice'");

		Individual individual = new Individual();
		individual.firstName = "Alice";
		ObjectSet os = db.get(individual);
		// Query By Example as in example S8

		Person alice = (Person)os.next();
		if(alice != null){
		
		
			alice.name = "Pan";
			alice.addresses = new Address[1];
			alice.addresses[0] = new Address();
			alice.addresses[0].city = "Oz";
			alice.addresses[0].street = "One Rabbit Way";
			// modifying alice
		

			db.set(alice);
			// calling db.set() with an object that is already stored
			// updates the object
			
		
		}
		db.close();

		S08_Query_By_Example.main(null);
		// we call sample S8 for the convenience to output 'Alice'
	}
}
