views:

209

answers:

2

What mechanism does db4o use to instatniate 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 (thugh with incorrect values).

If I can understand the mechanism perchaps i can track the bug I have.

I will appreciate any links :]

+2  A: 

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.

alamar
+1  A: 

Hi!

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

Goran