Re: S.O.D.A. database Query API - call for comments
Date: Tue, 8 May 2001 21:41:50 +0200
Message-ID: <9d9i7n$3j4$03$1_at_news.t-online.com>
mikito Harakiri wrote:
This is the "right-way-around" in a declarative query to an object database.
Note that declarative queries and object navigation are beautifully
complementary:
Code according to the current S.O.D.A. spec:
// your class model
class Car{
Wheel[] wheels;
// you have a given ObjectContainer to query against:
> Ok, let object Car contain Wheel (4 fields, actually:-). How exactly would
I
> find a Car given a Wheel; what indexes would I use? (Note that sql folks
are
> eager to provide exact sql statements -- I would like to see the code for
> objects either:-)
- navigation in the programming language finds members of objects
- declarative queries constrain objects by their members
class Wheel{
}
}
ObjectContainer db;
Wheel myWheel;
// get a new query object
Query carNode = db.query();
// constrain it to be of class car
carNode.constrain(new Car());
// add a subnode for wheels
Query wheelNode = carNode.getSubNode("wheels");
// use your given wheel to constrain this subnode
Constraint wheelConstraint =
wheelNode.constrain(myWheel);
// specifiy identity comparison
wheelConstraint.identity();
// get the result set
ObjectSet res = carNode.execute();
// The same code again in
// shorthand chained uncommented notation:
Query carNode = db.query();
carNode.constrain(new Car());
carNode.getSubNode("wheels").constrain(myWheel).identity();
ObjectSet res = carNode.execute();
Kind regards,
Carl
--- Carl Rosenberger db4o - database for objects - http://www.db4o.comReceived on Tue May 08 2001 - 21:41:50 CEST
