关于使用db4o工作的几个问题几个问题、工作、db4o

由网友(浅夏°非比晴空)分享简介:我想对db4o对象DATABSE,到目前为止我很喜欢我所看到的,但我也看到这篇文章计算器上的 db4o的经验?的说明,似乎很容易不是一切都很简单。 I am trying the db4o object databse and so far I quite like what I am seeing, but I a...

我想对db4o对象DATABSE,到目前为止我很喜欢我所看到的,但我也看到这篇文章计算器上的 db4o的经验?的说明,似乎很容易不是一切都很简单。

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 db4o experiences? indicating that not everything that seems so easy is easy.

现在,我有一个关于如何db4o的被用在现实世界中的应用程序的一些问题。所以,如果你有工作(尤其是在Web应用程序上下文中)与db4o的任何经验,我很愿意听到他们的声音。

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.

下面是我的问题:

你如何使用db4o存储对象时,管理对象的身份呢?** 我来自RDBMS的背景,你通常总是为每个表的主键/标识列,我不能想象现在如何在db4o的管理对象标识。

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.

例如,如果我的工作与NHibernate / mysql和发现由ID的用户对象的需要,我会做session.Load(PrimaryKey的),它会用它的PK进行检索。这也是很常见的PK被定义为自动递增的表定义。

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.

由于在db4o中没有这样的选择,我的想法是,以确定对象数据库中的某些对象使用一个GUID结构。

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?

有什么样的SQL Server Management Studio中(可能不太复杂)的db4o的世界吗?我想,以查看数据库文件中已存储的数据/对象。

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?

据我知道,当你重命名类,在数据库中的任何previously存储实例无法再恢复。有没有办法来解决这个问题?你如何处理对其中已经包含许多对象的实时数据库的更新?

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?

我可以从被保存到数据库中排除的属性?

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?

这似乎有点奇怪具有保存在数据库中,至少对我来说一个服务instace。

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? If the domain object is retrieved again, how can I make sure that the service is also injected in the instance again?

推荐答案

1)你怎么使用db4o存储对象时,管理对象的身份呢? 在db4o中你通常没有ID。 db4o的使用对象的身份来区分对象分开。因此,在存储器中的相同的对象将是该数据库的同一对象。

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.

只要一个你不序列化对象,这工作正常。但是只要对象是序列化/断开。这不再工作了。例如,在一个网络方案:将数据发送到浏览器。现在,你需要一些IDS稍后再识别的对象。

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.

我觉得这三个选项是可能的: - 使用 db4o的内部标识。然而,这id是不是永远。碎片整理数据库更改此ID。 - 以一href="http://developer.db4o.com/Documentation/Reference/db4o-8.0/net35/reference/Content/advanced_topics/ids_and_uuids.htm"相对=nofollow> db4o的UUID的的。但是db4o中的UUID是相当大 - 自己创建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)有一个对象管理器工具来查看数据库。然而,它极其有限的当前状态。在我看来,这是一个巨大的缺点进行了db4o。

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)您可以创建别名,重命名类和字段等。但是改变的继承层次结构不能正常工作。然后,你需要将旧数据复制到新的实例。

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)是的。你可以标记为瞬态与.NET的非序列化的属性或自定义属性。

4) Yes. You can mark fields as transient with the .NET-NonSerialized attribute or custom attributes.

阅读全文

相关推荐

最新文章