Transient Fields
The default MicroStream implementation fully supports the Java transient field modifier. Class members marked transient will not be persisted.
public class User
{
private String username;
//do not persist the users password
private transient String password;
}
It is possible to override the default behavior by implementing a custom PersistenceFieldEvaluator
.
PersistenceFieldEvaluator fieldEvaluator =
(clazz, field) -> !field.getName().startsWith("_");
EmbeddedStorageManager storage = EmbeddedStorage.Foundation()
.onConnectionFoundation(
c -> c.setFieldEvaluatorPersistable(fieldEvaluator)
)
.createEmbeddedStorageManager()
.start();