Question

It seems that db4o will ignore config parameters where you are trying to index a field on an object that is inherited from another object. For example, if I have the following:

public class foo
{
    private int theId;
    public int TheId {get{return theId;}set{theId=value;}}
}

public class bar:foo
{
    private string name;
    public string Name{get{return name;}set{name=value;}}
}

My configuration can resemble this:

IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();
config.Common.ObjectClass(typeof(foo)).ObjectField("theId").Indexed(true);

and this will work. However, if I try to do this:

IEmbeddedConfiguration config = Db4oEmbedded.NewConfiguration();
config.Common.ObjectClass(typeof(bar)).ObjectField("theId").Indexed(true);

the configuration is ignored; bar.TheId is not indexed.

I can see why this might be as designed, but I can find no documentation referencing this behavior, or noting this as a possible "gotcha". So is it a bug, or by design? It seems to me there might be many times when you would want to index the field only on a specific subclass.

Was it helpful?

Solution

I think it is by design. You can only index field on the classes it is declared on. This then also applies to all sub classes.

Afaik, indexing a inherited field only on a subclass is not possible right now.

Added a documentation task for this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top