简体   繁体   English

断开连接上下文中的db4o:如何处理保存/更新

[英]db4o in disconnected context: how to handle save/update

The application I am working on is client/server with REST communication between them. 我正在使用的应用程序是客户端/服务器,它们之间具有REST通信。 I want to use db4o on server side. 我想在服务器端使用db4o。 The client can update or create entries. 客户端可以更新或创建条目。 Thus, the object comes back to server from the client for update from "out of the ObjectContainer". 因此,对象从客户端返回到服务器以从“超出ObjectContainer”进行更新。

Let: 让:

  public class IdHolder
  {
    public Guid Id {get; set;}
  }

  public class MyClass : IdHolder
  {
    public string SomeData {get; set;}
    public IdHolder Child {get; set;}
  }

As you ca see, the class MyClass has a reference to IdHolder. 如您所见,类MyClass引用了IdHolder。

According to db4o documentation I have 2 solutions: 1. internal Uuid 2. manual Guid handling 根据db4o 文档,我有2个解决方案:1.内部Uuid 2.手动Guid处理

In case 1., the client must have a reference to db4o assembly to be aware of specific type db4o.Uuid which is not good. 在情况1中,客户机必须具有对db4o程序集的引用,以了解特定类型的db4o.Uuid不好。

In case 2. (which is implicite in the classes definition above) the Guid handling is convinient but db4o is not aware of inner IdHolder reference. 在情况2中(在上面的类定义中是隐式的),Guid处理很方便,但是db4o不了解内部IdHolder引用。 For instance: 例如:

  • o1 is a IdHolder saved in DB o1是保存在数据库中的IdHolder
  • o2 is a MyClass with o2.Child == o1 o2是带有o2.Child == o1的MyClass

When o2 is sent to Server for saving, a duplicate entry of o1 is saved in DB because db4o does not know that o1 already exists and can be found by its o1.Id. 将o2发送到服务器进行保存时,o1的重复条目将保存在DB中,因为db4o不知道o1已经存在并且可以通过其o1.Id找到。

The question is: what is the best way to handle disconnected scenarios using db4o? 问题是:使用db4o处理断开连接的方案的最佳方法是什么?

Edit: 编辑:

This part if the doc deals with such an issue. 如果文档处理了此问题, 则此部分 "Merging". “合并”。 Does not seem very satisfying to me. 对我来说似乎不是很满意。 I remain open to your conceptual/technical ideas. 我仍然欢迎您的概念/技术想法。

There's basically no support for that on the db4o side. db4o方面基本上不支持该功能。 The ' merging' like the doc says is basically the best option you've got. 像文档所说的“ 合并”基本上是您拥有的最佳选择。

db4o is not very optimal for web apps, because of this. 因此,db4o对于网络应用程序不是很理想。 (And it also doesn't scale, since it inherently single threaded.) (并且它也不会扩展,因为它本质上是单线程的。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM