tags:

views:

514

answers:

1

I am trying the db4o object databse and so far I quite like what I am seeing, but I also read this post on stackoverflow http://stackoverflow.com/questions/21207/db4o-experiences/24499#24499 indicating that not everything that seems so easy is easy.

Right now, I have some questions regarding on how db4o is used in real world apps. So if you have any experience in working (especially in web app context) with db4o, I would love to hear them.

Here are my questions:

How do you manage object identity when working with db4o stored objects?
Coming from RDBMS background where you normally always have a primary key / identity column for every table, I cant imagine right now on how to manage object identity in db4o.

For example, if I was working with NHibernate / mysql and needed to find a User object by id, I would do session.Load(primaryKey) and it will be retrieved by its PK. It is also very common that the PK is defined as auto increment in the table definition.

As there is no such option in db4o, my thought was using a Guid struct in order to identify some objects in the object database.

Any tools to view the stored objects in the db?
Is there something like SQL Server Management Studio (probably less sophisticated) in the db4o world? I would like to view the already stored data / objects in the db file.

Are you screwed when renaming your domain objects?
As far as I know when you rename a class, any previously stored instances in the db cannot be retrieved anymore. Is there a way to work around this issue? How do you deal with updates against a live database which already contains many objects?


EDIT:

I almost forgot this one:

Can I exclude properties from being saved to the DB?
If for example one domain object holds a reference to a (stateless) service object, then the service object will also be persisted if the domain object gets persisted, right?

It seems a bit odd to have a service instace saved in the database, at least to me. Can you exclude the service instance from being saved? But if the domain object is retrieved again, how can I make sure that the service is also injected in the instance again?

+9  A: 

1) How do you manage object identity when working with db4o stored objects? In db4o you have normally no id. db4o uses the object-identity to distinguish the object apart. So the same object in memory is going to be the same object for the database.

As long a you don't serialize object this works fine. However as soon as objects are serialized / disconnected this doesn't work anymore. For example in a web-scenario: You send the data to the browser. Now you need to identify the objects later again by some ids.

I think this three options are possible: - Use the db4o internal id. However this id isn't forever. Defragmenting the database changes this id. - Using db4o's UUIDs. But db4o UUIDs are quite large - Creating ids by yourself

2) There's a Object-Manager Tool to look at the database. However it extremely limited in its current state. In my opinion this is a huge drawback for db4o.

3) You can create aliases, rename classes and fields etc. However changing the inheritance-hierarchy doesn't work. Then you need to copy the old data to new instances.

4) Yes. You can mark fields as transient.

Gamlor