db4o 4.0

com.db4o.config
Interface ObjectClass


public interface ObjectClass

configuration interface for classes.

Examples: ../com/db4o/samples/translators/Default.java.

Use the global Configuration object to configure db4o before opening an ObjectContainer.

Example:
Configuration config = Db4o.configure();
ObjectClass oc = config.objectClass("package.className");
oc.updateDepth(3);
oc.minimumActivationDepth(3);


Method Summary
 void cascadeOnActivate(boolean flag)
          sets cascaded activation behaviour.
 void cascadeOnDelete(boolean flag)
          sets cascaded delete behaviour.
 void cascadeOnUpdate(boolean flag)
          sets cascaded update behaviour.
 void compare(ObjectAttribute attributeProvider)
          registers an attribute provider for special query behavior.
 void maximumActivationDepth(int depth)
          sets the maximum activation depth to the desired value.
 void minimumActivationDepth(int depth)
          sets the minimum activation depth to the desired value.
 ObjectField objectField(java.lang.String fieldName)
          returns an ObjectField object to configure the specified field.
 void persistStaticFieldValues()
          turns on storing static field values for this class.
 void rename(java.lang.String newName)
          renames a stored class.
 void storeTransientFields(boolean flag)
          allows to specify if transient fields are to be stored.
 void translate(ObjectTranslator translator)
          registers a translator for this class.
 void updateDepth(int depth)
          specifies the updateDepth for this class.
 

Method Detail

cascadeOnActivate

public void cascadeOnActivate(boolean flag)
sets cascaded activation behaviour.

Setting cascadeOnActivate to true will result in the activation of all member objects if an instance of this class is activated.

The default setting is false.

Parameters:
flag - whether activation is to be cascaded to member objects.
See Also:
ObjectField#cascadeOnActivate(), ObjectContainer#activate(),
Using callbacks, Why activation?

cascadeOnDelete

public void cascadeOnDelete(boolean flag)
sets cascaded delete behaviour.

Setting cascadeOnDelete to true will result in the deletion of all member objects of instances of this class, if they are passed to ObjectContainer#delete().

Caution !
This setting will also trigger deletion of old member objects, on calls to ObjectContainer#set().

An example of the behaviour:
ObjectContainer con;
Bar bar1 = new Bar();
Bar bar2 = new Bar();
foo.bar = bar1;
con.set(foo); // bar1 is stored as a member of foo
foo.bar = bar2;
con.set(foo); // bar2 is stored as a member of foo

The last statement will also delete bar1 from the ObjectContainer, no matter how many other stored objects hold references to bar1.

The default setting is false.

Parameters:
flag - whether deletes are to be cascaded to member objects.
See Also:
ObjectField#cascadeOnDelete(), ObjectContainer#delete(),
Using callbacks

cascadeOnUpdate

public void cascadeOnUpdate(boolean flag)
sets cascaded update behaviour.

Setting cascadeOnUpdate to true will result in the update of all member objects if a stored instance of this class is passed to ObjectContainer#set().

The default setting is false.

Parameters:
flag - whether updates are to be cascaded to member objects.
See Also:
ObjectField#cascadeOnUpdate(), ObjectContainer#set(),
Using callbacks

compare

public void compare(ObjectAttribute attributeProvider)
registers an attribute provider for special query behavior.

The query processor will compare the object returned by the attribute provider instead of the actual object, both for the constraint and the candidate persistent object.

Preinstalled attribute providers are documented in the sourcecode of com.db4o.samples.translators.Default.java#defaultConfiguration().

Parameters:
attributeProvider - the attribute provider to be used

maximumActivationDepth

public void maximumActivationDepth(int depth)
sets the maximum activation depth to the desired value.

A class specific setting overrides the global setting.

Parameters:
depth - the desired maximum activation depth
See Also:
Why activation?, ObjectClass#cascadeOnActivate()

minimumActivationDepth

public void minimumActivationDepth(int depth)
sets the minimum activation depth to the desired value.

A class specific setting overrides the global setting.

Parameters:
depth - the desired minimum activation depth
See Also:
Why activation?, ObjectClass#cascadeOnActivate()

objectField

public ObjectField objectField(java.lang.String fieldName)
returns an ObjectField object to configure the specified field.

Parameters:
fieldName - the fieldname of the field to be configured.

Returns:
an instance of an ObjectField object for configuration.

persistStaticFieldValues

public void persistStaticFieldValues()
turns on storing static field values for this class.

By default, static field values of classes are not stored to the database file. By turning the setting on with this switch, all static field values of this classes are stored, every time a database file is opened.

This option will slow down the process of opening database files and the stored objects will occupy space in the database file.


rename

public void rename(java.lang.String newName)
renames a stored class.

Use this method to refactor classes.

Examples: ../com/db4o/samples/rename.

This feature is not available in db4o community edition.

Parameters:
newName - the new fully qualified classname.

storeTransientFields

public void storeTransientFields(boolean flag)
allows to specify if transient fields are to be stored.
The default for every class is false.

Parameters:
flag - whether or not transient fields are to be stored.

translate

public void translate(ObjectTranslator translator)
registers a translator for this class.

Preinstalled translators are documented in the sourcecode of com.db4o.samples.translators.Default.java#defaultConfiguration().

Example translators can also be found in this folder.

Parameters:
translator - this may be an ObjectTranslator or an ObjectConstructor
See Also:
ObjectTranslator, ObjectConstructor

updateDepth

public void updateDepth(int depth)
specifies the updateDepth for this class.

see the documentation of ObjectContainer.set() for further details.

The default setting is 0: Only the object passed to ObjectContainer.set() will be updated.

Parameters:
depth - the depth of the desired update for this class.
See Also:
Configuration#updateDepth(), ObjectClass#cascadeOnUpdate(), ObjectField#cascadeOnUpdate(),
Using callbacks

db4o 4.0