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

Object creation questions



Falko, Lars, or someone,

Can you explain about object creation with ozone in more detail? I'm
spending ages going round in circles.

Particular questions are:
1) Do all persistent classes need a constructor with no parameter and no
body?
1b) If so, why doesn't the default constructor work?
2) Do all persistent objects need to be created by calling the
no-parameter, no-body constructor? or can you call another constructor?
If you call another constructor does it have to call the ( ) {} one?
3) What is the difference between creating objects from outside the db
server and creating them within the db server?
3b) I seem to be able to create db objects within other db objects with
calls to new, rather than to .createObject() but their behaviour seems
erratic (see below). Is this supposed to work or is it inadvisable?
4) Am I right in thinking that if you create an object with
database().createObject(myObject), the constructor of myObject can't
create other objects - I get an "object is not yet associated to a
database container" exception.
5) Can you explain about named objects, e.g. do names have to be unique
within DB or only unique within a class of objects?

Sorry for so many questions!

Thanks,
Charles

Here's an outline of what I want to do:

Client: rootThingy = db.createObject(root_object_name);
Client: rootThingy.addSomething_update(param);

rootThingy.addSomething_update(param) {
Something anObj = new Something(param);
}

where Something is an object I want to be persistent, with a constructor
like:

Something ( ) {
myField = param;
}

Now, this seems to create the objects OK (from debug messages). Also, if
I want to read myField later, I can navigate from root_object_name and
get it OK.
However, if I want to call a method of Something, it doesn't work.

PS An example with more than two layers of db objects (ie more than
garage and car), where objects at all layers are manipulated would be
handy.
C