Question

i have a problem with db4o that i'm unable to fix. i have 2 classes.

public class Profile {
    private String Name;
    private List<Action> Actions;

    public String getName() {
        return Name;
    }

    public void setName(String Name) {
        this.Name = Name;
    }

    public List<Action> getActions() {
        if (Actions == null)
            Actions = new ArrayList<Action>();
        return Actions;
    }
}

and the other class.

public class Action {
   private String _Name;

   public Action(String Name) {
    _Name = Name;
   }

   public String getName() {
    return _Name;
   }
}

the thing is when i store in db4o for the first time the Profile and the list of actions save fine aswell. when i update (adding or removing items from the list of actions) it wont reflect in the database (db4o).

what i do to save the data is just to db4o.store(Profile). i dont know if maybe i must to store the list something like db4o.store(Profile.Actions).

any help would be appreciated.

Regards.

Was it helpful?

Solution

It looks like your update depth isn't set properly. To update the inner list of your Profile class, you need to set up your configuration with a higher update depth. See this article and this article in the db4o references.

For a List, I recommend an update depth of 2 or higher.

EmbeddedConfiguration configuration = Db4oEmbedded.newConfiguration();
configuration.common().objectClass(Profile.class).updateDepth(2);

An update depth of 2 will update all the way down to the Action object, including the Action itself (I believe) so that if you change an Action that's already in the list, it will update too. Just be careful, as setting the update depth too high can cause performance issues.

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