You are here: Basics Operations & Concepts > Update Concept

Update Concept

Updating objects in db4o is as easy as storing them. You just call then store-method again to update a object. How does a update work? There are two main questions. First, how does db4o recognize a object so that it knows whenever it should update a object or store it as a new object? And what's the scope of updates? All all objects updated? Or just the objects you explicitly store?

Object Recognition

How does db4o know which object needs to be updated and which object has to be stored as new object? Well db4o uses the object-identity and looks up it if has loaded this object. If the object was loaded by db4o, it is an existing object and will be updated. Otherwise it has to be a new object and is stored as a new object.

Update Depth

When you update of a object, db4o only stores the changes to a certain depth. This update depth avoids that db4o needs to go through the whole object graph and find out which objects have changed.

By default this update depth is one. This means when you update a object, only the changes on that object are stored. Changes on other objects are not included. When you want to store changes of multiple objects you need either to increase the update-depth, store each object individually or use transparent persistence.

Take a look at this concrete example to see how the update-depth affects you're operations. See "Update Depth In Action"

Since collection are regular object in db4o the update depth also applies to collections. See "Updating Collections"

If you want to automate the update process of object: See "Transparent Persistence"