db4o open source object database
db4o :: Product News Blog

Syndicate This

Wednesday, August 03, 2005

db4o 4.6 dev and 5.0 M1 - as native as possible

Our 4.6 development release and our 5.0 M1 sneak preview are now available on the download center page of the db4o website.

Both releases show one major goal of db4o very well:
We want db4o to be as native as possible, perfectly object-oriented, an ideal match for the concepts of the programming language that you are using.

With db4o you do not need to work against proprietary features that we produce. All concepts that db4o supplies for working against a database are concepts of your Java/C# programming language and you are very likely to be using them already:
(1) Class schemas are good persistence schemas.
(2) Collections work great as Query resultsets.
(3) Java and C# are ideal languages to express queries.

db4o has been very good at (1) for a long time, here is how the latest builds and upcoming releases improve on (2) and (3):

(2) The ObjectSet returned by a query now extends java.util.List, java.util.Iterator and System.Collections.IList.

Extending these interfaces, ObjectSet works a lot better as a source for UI controls. You can now use "for each" and you do not even need to refer to the ObjectSet interface from your code, the collections of your programming language will work just as well:

C#
----
IList cars = query.Execute();
foreach (Car car in cars){
car.Drive();
}


Java
----
List<car> cars = query.execute();
for (Car car : cars){
car.drive();
}


(3) db4o supplies native queries in version 5.0.

From a user perspective the concept is straightforward:
db4o behaves as if it would call one single callback method for all stored instances of a class. You implement the callback method in your code and return true, if you want a specific object to be included in the query resultset or false, if the object does not match the criteria that you expect. Here is a simple example:

C#
----
IList<cat> cats = objectContainer.Query<cat>(delegate (Cat cat) {
return cat.Name.Equals("Occam")
cat.Name.Equals("Zora");
});


Java
----
List<cat> cats = objectContainer.query(new Predicate <cat> () {
public boolean match(Cat cat){
return cat.name.equals("Occam")
cat.name.equals("Zora");
}
});


Native queries have the potential to boost your productivity, because they:
- are 100% typesafe
- are 100% compile-time checked
- are 100% refactorable
- allow any complex method call
- obey OO principles
- do not break encapsulation

Native queries are perfect Java/C#, you do not have to learn another query language or a special query API. They even work against plain collections, without the presence of a database.

The db4o 5.0 sneak preview already provides usable native queries but they do not execute very fast yet, since db4o will indeed instantiate every stored object.

For the 5.0 final release we are working on an optimizer that will "understand" the code that you place in the callback method, to operate against database indexes where this is possible, to provide fast query execution, exactly like it is currently available with S.O.D.A. and query-by-example queries.

We will soon publish more information about native queries since we believe that they deserve to become an IT standard.

Powered by Blogger