Question

What mechanism does db4o use to instantiate stored objects ?

My class isn't Serializable and doesn't provide zero argument constructor and the only constructor throws NullPointerException when it's argument is null.

In spite of that, db4o can still instantiate stored objects of that class (though with incorrect values).

If I can understand the mechanism perhaps i can track down the bug I have.

I will appreciate any links :]

Was it helpful?

Solution

Db4o is open source so you might take a look at the source. The basic idea is the use of type handlers which enable serialization and deserialization of objects. There's a simple example provider for advanced users requiring a custom type handler. Object construction can use constructors or bypass constructor if no suitable constructor exists. The mentioned constructor bug can be prevented by using configuration settings which instructs db4o to call constructors anyway.

You may wish to post this question on db4o forums to get a more detailed explanation from the developers.

Goran

OTHER TIPS

It uses sun's (or your other jvm's) special api to instantiate objects without checking access and running constructors.

The bug you're having is most likely due to the fact that no constructors have been run, including implicit ones which set up default values on fields.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top