db4o Developer Community

db4o open source object database, native to Java and .NET
Welcome to db4o Developer Community Sign in | Join
in Search
More Search Options

Lost data between calls to Close()

Last post 05-22-2008, 03:55 PM by Yokumo. 2 replies.
Sort Posts: Previous Next
  •  05-13-2008, 08:12 PM 49020

    Lost data between calls to Close()

    I am using db4o 7.2 for .NET 3.5. I save some data, call Close(). The data file keeps it size but all queries return empty collections after calling db.Close() I AM calling db.Commit() after storing the objects. Is this really possible? I'd like to experiment with db4o but I'm stuck.

     

    IObjectContainer db = Db4oFactory.OpenFile(dbFileName);

    StoreFirstCar(db); // from tutorial

    db.Commit();

    db.Close();

     

    db = Db4oFactory.OpenFile(dbFileName);

    IList cars = db.Query<Car>();

    int count = cars.Count; // count is 0 !

  •  05-14-2008, 04:03 AM 49025 in reply to 49020

    Re: Lost data between calls to Close()

    inv:
    IList cars = db.Query<Car>();

    This looks strange... usually (for me as a Java-db4o-user) a call to #query() without any parameters creates an SODA-Query-Object, which is something completely different than executing a query which should give you an ObjectSet.

    So I would recommend to use something like:

    IList cars = db.Query<Car>(typeof(Car));

    HTH, Maik 


    http://db4o.blogspot.com/
  •  05-22-2008, 03:55 PM 49197 in reply to 49025

    Re: Lost data between calls to Close()

    If I understood the tutorial correctly, my objects are stored in the .yap-File.
    I tried the examples from the tutorial and stored some pilots in the Container.

    Now I wrote my own ConsoleApplication and wanted to read the stored pilots from the file with:

    // accessDb4o
    IObjectContainer mydb = Db4oFactory.OpenFile("C:/Temp/test.yap");
                try
                {
                    // retrieveAllPilots
                    result = mydb.QueryByExample(typeof(Pilot));
                    ListResult(result);
                   
                    Console.ReadLine();
                }

                finally
                {
                    mydb.Close();
                }

     
    However I always get an empty output, lilke: 0 0

    which absically means that thgere are no objects in the container.  :(

    Did I do something wrong?
     

View as RSS news feed in XML