A few questions about working with db4o

試著忘記壹切 提交于 2019-11-28 18:22:38

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 with the .NET-NonSerialized attribute or custom attributes.

In objects oriented databases (such as db4o) object identity should not really be used. Instead one used queries and navigation. First perform a query to get one/some objects, then use navigation to get to others.

'Navigation' means that you just follow the fields/references in any loaded object.

Using object identifiers can be considered bad style, most application (that I know) don't use them at all.

While doing some work with DB4O, I wrote a simple DB4O object browser that works much better than the included one. Give it a try, it's open source.

http://sourceforge.net/projects/db4oviewer/develop

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!