In real world objects are referenced by each other creating deep reference structures.
This chapter will give you an overview of how db4o deals with structured objects.
For an example we will use a simple model, where Pilot class is referenced from Car class.
01/* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com */ 02
package com.db4odoc.structured; 03
04
public class Pilot { 05
private String name; 06
07
private int points; 08
09
public Pilot(String name, int points) { 10
this.name = name; 11
this.points = points; 12
} 13
14
public int getPoints() { 15
return points; 16
} 17
18
public void addPoints(int points) { 19
this.points += points; 20
} 21
22
public String getName() { 23
return name; 24
} 25
26
public String toString() { 27
return name + "/" + points; 28
} 29
}
01/* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com */ 02
package com.db4odoc.structured; 03
04
public class Car { 05
private String model; 06
07
private Pilot pilot; 08
09
public Car(String model) { 10
this.model = model; 11
this.pilot = null; 12
} 13
14
public Pilot getPilot() { 15
return pilot; 16
} 17
18
public void setPilot(Pilot pilot) { 19
this.pilot = pilot; 20
} 21
22
public String getModel() { 23
return model; 24
} 25
26
public String toString() { 27
return model + "[" + pilot + "]"; 28
} 29
}