You are here: Advanced Features > Type Handling > Object Construction

Object Construction

How does db4o construct its objects when it loads it from the database?

Bypassing the Constructor

By default db4o creates the object and bypasses any constructor. It does that by using the available methods on the platform. After that it uses reflection of fill the fields of the object with the content. After that object creating process is finished and the object is ready to be used.

Using the Constructor

Optionally db4o can also create objects using the constructor. In that case db4o tries to find a constructor which is can use. db4o starts to tries out all constructors, starting with the constructor with the least arguments. As soon a constructor can be called without throwing an exception, it is used. When a constructor has arguments db4o calls it with default values for all arguments. For reference-types that’s null, for number zero and for other values types the appropriate default. When no constructor can be found, db4o will throw an appropriate exception.

Special Construction

The last possibility for db4o to construct objects is by special handlers. Either with translators or type handlers.