[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objects inside objects don't persist??!?



On Thu, 01 Jun 2000, Amy wrote:
> I am using LocalDatabase to save an object into ozone.
> One of the members of this object's class is a Vector which I initialize
> 
> in the class constructor.
> 
> When I close the database, re-open it and retrieve my object
> the contents of the Vector are gone!!!
> 
> What is going on?
Hmmm... I don't know. I just tested this. No problems. 

My database object looks like:

public class AutoImpl extends OzoneObject implements Auto {
   
   static final long serialVersionUID = 1L;

   String	name = "Ford";

   int		age = 0;

   Auto		link;
   
   Vector	v;
   
   
   public AutoImpl() {
     // System.out.println ("Auto ctor...");
      v = new Vector();
      v.add ("dani");
      }

    ....
    }

The main code is:

    public static void main (String[] args) throws Exception {

        LocalDatabase ldb = new LocalDatabase();
        ldb.open ("/tmp/db");
        
        ExternalDatabase db = ldb;

        Auto auto = (Auto)db.objectForName ("name");
        if (auto == null) {
            System.out.println ("creating new auto...");
            auto = (Auto)db.createObject (AutoImpl.class.getName(), OzoneInterface.Public, "name");
            }
        auto.print();
        
        db.close();
        }

In the first run an Auto object is created. The second run retrieves this
object from the database and correctly prints its content including the vector.
Please check your code.


Falko
-- 
______________________________________________________________________
Falko Braeutigam                         mailto:falko@softwarebuero.de
softwarebuero m&b (SMB)                    http://www.softwarebuero.de