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 - 2007 db4objects Inc. http://www.db4o.com */ 02
03
package com.db4odoc.selectivepersistence; 04
05
public class Test { 06
transient String transientField; 07
08
String persistentField; 09
10
public Test(String transientField, String persistentField) { 11
this.transientField = transientField; 12
this.persistentField = persistentField; 13
} 14
15
public String toString() { 16
return "Test: persistent: " + persistentField 17
+ ", transient: " + transientField; 18
} 19
20
}
The following example demonstrates the effect of transient keyword on db4o:
01private static void saveObjects(Configuration configuration){ 02
new File(DB4O_FILE_NAME).delete(); 03
ObjectContainer container = Db4o.openFile(configuration, DB4O_FILE_NAME); 04
try 05
{ 06
Test test = new Test("Transient string","Persistent string"); 07
container.set(test); 08
} 09
finally 10
{ 11
container.close(); 12
} 13
}
01private static void retrieveObjects() 02
{ 03
ObjectContainer container = Db4o.openFile(DB4O_FILE_NAME); 04
try 05
{ 06
ObjectSet result = container.query(Test.class); 07
listResult(result); 08
} 09
finally 10
{ 11
container.close(); 12
} 13
}