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

onCreate, onDelete are pretty cool




Hi,
I remember a discussion about using init methods in your objects because
the constructor can't create persistent objects. I found this out today
with the old message:

connected...
Company not found creating...
Exception in thread "main" org.ozoneDB.OzoneInternalExc:
java.lang.RuntimeException: Object is not (yet) associated to a database
container.
	at org.ozoneDB.ExternalDatabase.sendCommand(ExternalDatabase.java:532)
	at org.ozoneDB.ExternalDatabase.sendCommand(ExternalDatabase.java:500)
	at org.ozoneDB.ExternalDatabase.createObject(ExternalDatabase.java:732)
	at org.ozoneDB.ExternalDatabase.createObject(ExternalDatabase.java:726)
	at Client.main(Client.java:42)

Well, I had previously found the onDelete method to delete referenced
objects which works great and it finally dawned on me that the onCreate
method is the mirror callback method.

    public CompanyImpl() throws Exception {
        System.out.println( getClass().getName() + " ctor..." );
	this.dateCreated = new Date();
    }
    public void onCreate() throws Exception {
	System.out.println(getClass().getName() + " onCreate ..." );
	OzoneInterface ob = this.database();
	this.people = (People)ob.createObject(PeopleImpl.class.getName());
	this.address = (Address)ob.createObject(AddressImpl.class.getName());
    }

This works great and although not completely transparent at least makes
sense.

Thanks,
Eric

----------------------------------------------------------------------
Post a message:         mailto:ozone-users@ozone-db.org
Unsubscribe:            mailto:ozone-users-request@ozone-db.org?body=unsubscribe
Contact adminstrator:   mailto:ozone-users-owner@ozone-db.org
Read archived messages: http://www.ozone-db.org/
----------------------------------------------------------------------