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

Re: onCreate, onDelete are pretty cool



On Tue, 03 Jul 2001, Eric Richardson wrote:
> 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.

Yes, it isn't completely transparent but the only solution that we found. The
problem is that a (database) object does not exist until it is created calling
the ctor. Clear, of course. But if it's not there I cannot assign the database
container to it and so all database related methods don't work because they all
use the container() method from inside the database object - classic chicken egg
problem.


Falko
-- 
______________________________________________________________________
Falko Braeutigam                              mailto:falko@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com


----------------------------------------------------------------------
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/
----------------------------------------------------------------------