db4o problem with graph of objects

Posted by Staszek28 on Stack Overflow See other posts from Stack Overflow or by Staszek28
Published on 2010-05-16T15:30:55Z Indexed on 2010/05/16 15:40 UTC
Read the original article Hit count: 257

Filed under:

I am a new to db4o. I have a big problem with persistance of a graph of objects. I am trying to migrate from old persistance component to new, using db4o.

Before I peristed all objects its graph looked like below (Take a look at Zrodlo.Metadane.abstrakt string field with focused value) [its view from eclipse debuger] with a code:

  ObjectContainer db=Db4o.openFile(DB_FILE);
    try {
        db.store(encja);
        db.commit();            
    } finally{
        db.close();         
    }

alt text

After that, I tried to read it with a code:

ObjectContainer db=Db4o.openFile((DB_FILE));

    try{
        Query q = db.query();
        q.constrain(EncjaDanych.class);
        ObjectSet<Object> objectSet = q.execute();
        logger.debug("objectSet.size" + objectSet.size());
        EncjaDanych encja = (EncjaDanych) objectSet.get(0);
        logger.debug("ENCJA"  + encja.toString());
        return encja;
    }finally{
        db.close();         
    }       

and I got it (picture below) - string field "abstrakt" is null now !!! alt text

I take a look at it using ObjectManager (picture below) and abstrakt field has not-null value there!!! The same value, that on the 1st picture.

alt text

Please help me :) It is my second day with db4o. Thanks in advance!

I am attaching some code with structure of persisted class:

public class EncjaDanych{ Map mapaIdRepo = new HashMap(); public Map mapaNazwaRepo = new HashMap(); }

© Stack Overflow or respective owner

Related posts about db4o