This topic applies to Java version only
You can use the transient keyword to indicate that a field is not part of the persistent state of an object:
01/* Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com */ 02
03
package com.db4odoc.selpersist; 04
05
06
public class Test { 07
transient String transientField; 08
String persistentField; 09
10
public Test(String transientField, String persistentField) 11
{ 12
this.transientField = transientField; 13
this.persistentField = persistentField; 14
} 15
16
public String toString() 17
{ 18
return "Test: persistent: " + persistentField + ", transient: " + transientField ; 19
} 20
21
}
The following example demonstrates the effect of transient keyword on db4o:
01public static void saveObjects(){ 02
new File(YAPFILENAME).delete(); 03
ObjectContainer oc = Db4o.openFile(YAPFILENAME); 04
try 05
{ 06
Test test = new Test("Transient string","Persistent string"); 07
oc.set(test); 08
} 09
finally 10
{ 11
oc.close(); 12
} 13
}
01public static void retrieveObjects() 02
{ 03
ObjectContainer oc = Db4o.openFile(YAPFILENAME); 04
try 05
{ 06
ObjectSet result = oc.query(Test.class); 07
listResult(result); 08
} 09
finally 10
{ 11
oc.close(); 12
} 13
}