Examples

C1.java
01/* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com */ 02 03class C1 { 04 private String s; 05 06 private C1(String s) { 07 this.s=s; 08 } 09 10 public String toString() { 11 return s; 12 } 13}

The above class is fine for use with and without callConstructors set.

C2.java
01/* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com */ 02 03class C2 { 04 private transient String x; 05 private String s; 06 07 private C2(String s) { 08 this.s=s; 09 this.x="x"; 10 } 11 12 public String toString() { 13 return s+x.length(); 14 } 15}

The above C2 class needs to have callConstructors set to true. Otherwise, since transient members are not stored and the constructor code is not executed, toString() will potentially run into a NullPointerException on x.length().

C3.java
01/* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com */ 02 03class C3 { 04 private String s; 05 private int i; 06 07 private C3(String s) { 08 this.s=s; 09 this.i=s.length(); 10 } 11 12 public String toString() { 13 return s+i; 14 } 15}

The above C3 class needs to have callConstructors set to false (the default), since the (only) constructor will throw a NullPointerException when called with a null value.

C4.java
01/* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com */ 02 03class C4 { 04 private String s; 05 private transient int i; 06 07 private C4(String s) { 08 this.s=s; 09 this.i=s.length(); 10 } 11 12 public String toString() { 13 return s+i; 14 } 15}

This class cannot be cleanly reinstantiated by db4o: Both approaches will fail, so one has to resort to configuring a translator.