简体   繁体   English

Db4o中不受支持的类层次结构更改

[英]unsupported class hierarchy change in Db4o

I have: 我有:

static class Db4o...

and: 和:

class Db4oBase... // which uses Db4o class

where I can: 我可以在哪里:

class Customer : Db4oBase
{
    public Customer(string name)
    {
    }
}

so that I can: 这样我可以:

Customer customer = new Customer("Acbel Polytech Philippines");

customer.store();  //something like that

It worked, until sometime in my development, the code below suddenly bugged down: 它一直有效,直到我开发某个时候,下面的代码突然出现错误:

class Db4o
{
    .
    .
    .
    public static IObjectSet Retrieve(object obj)
    {
        IObjectSet objectSet = null;

        objectSet = container.Ext().QueryByExample(obj); // This part of the code
                                                         // throws a unsupported
                                                         // class hierarchy.

        return objectSet;
    }
}

The QueryByExample instruction throws an unsupported class hierarchy. QueryByExample指令将引发不受支持的类层次结构。 Does anybody know what should I do? 有人知道我该怎么办吗?

It happened when you: 当您:

  1. Code a class and then run the program. 编写一个类,然后运行该程序。
  2. Later you modify the code and add/change the parent class (changing the hierarchy) 稍后,您修改代码并添加/更改父类(更改层次结构)
  3. Finally you run again and ... CRASSHHH. 最终,您再次运行并... CRASSHHH。

yes, Hierarchy (inheritance) is supported but change it is not so simple to apply on existent file. 是的,支持层次结构(继承),但要更改其应用于现有文件并不是那么简单。

Somehow your class hierachy has changed -- which is not directly supported by db4o . 您的类层次结构以某种方式发生了变化-db4o 不直接支持 What ever happend, you have the following options (from db4o docs): 无论发生什么,您都有以下选项(来自db4o docs):

  • Create the new hierarchy with different names, preferably in a new package 使用不同的名称创建新的层次结构,最好在新程序包中
  • Copy all values from the old classes to the new classes. 将所有值从旧类复制到新类。
  • Redirect all references from existing objects to the new classes. 将所有引用从现有对象重定向到新类。

Okay this is what I did to remove the exception. 好的,这就是我删除异常的方法。 I just created another clean database file. 我刚刚创建了另一个干净的数据库文件。 But I haven't find out what is the root cause that led to that error. 但是我还没有找出导致该错误的根本原因。 No time for that yet. 现在还没有时间。 But it removed the "Unsupported class hierarchy change" exception. 但是,它删除了“不支持的类层次结构更改”异常。 So if any of you encountered this you might want to try doing what I've done but if you know the root cause, please post it here as an answer. 因此,如果您遇到任何此问题,您可能想尝试做我所做的事情,但是如果您知道根本原因,请在此处张贴它作为答案。 Thanks. 谢谢。

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

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