You are here: Object Lifecycle > Update Depth

Update Depth

Update depth term is used to determine a number of levels of member objects down the hierarchy, which will be updated automatically, when the top-level object is updated. Understanding of update depth and its performance impact is especially important for working with deep object graphs and collections.

The default update depth value is 0, which means that objectContainer#set(object) method will only update the object passed as a parameter and any changes to its member objects will be lost.

Update depth can be changed globally or for a specific class.

Global update depth settings:

Java:

configuration.common().updateDepth(depth)

Class-specific update settings:

Java:

configuration.common().objectClass(ListObject.class).cascadeOnUpdate(flag);

configuration.common().objectClass(ListObject.class).updateDepth(depth);

Here depth parameter specifies the number of member object levels down the hierarchy, which will be updated when the top-level object is saved.

Flag parameter determines whether update operation should be cascaded to all the member objects.

Note, that the recommended setting for the update depth is 0, i.e. the default one. Setting update depth to a higher value inevitably leads to performance downgrade. Storing the required amount of levels can instead be achieved by using a special store method:

Java:

objectContainer.ext().store(object, updateDepth);

Further reading:

Update Depth for Structured Objects

Collections Update Depth