 |
db4o - persistence made easy
Posted by herkules on February 14, 2005 at 06:00 AM | Comments (4)
There has been an announcement recently that the db4o database has gone opensource. Db4o? Heard about it, visited the website years ago, remember it looked nice....
The download is small, even smaller is the jar: 320kb - nothing more is needed.
Checking it out reveals really cool features. All kinds of persistence I've seen so far needed some kind of prerequisites to be taken: special base classes, enhancements, mapping scripts, precompilers or even hand-crafted read/write code. At least some DB initialisation. Nothing of that in db4o. Take any object, present it to the database and consider it persisted. It's really that easy:
ObjectContainer db = Db4o.openFile("myDB");
MyObject o = new MyObject( "Hello", "World" );
db.set( o );
Retrieving is not more difficult:
Query query=db.query();
query.constrain( MyObject.class );
ObjectSet result = query.execute();
while(result.hasNext()) {
System.out.println( result.next() );
}
For now, I didn't dig very deep. Updating and deleting is easy as well. For it is a database, there are query APIs implementing QBE and S.O.D.A.. This is everything I need and maybe already more than I can handle :). The magic words 'transaction' and 'client/server' also show up in the tutorial, so I suppose I will not be left alone when it gets more complex.
The database itself is just a plain, very small file. If you are looking for a truely lightweight persister and can live with the GPL, give it a try. It's so light that it makes sense to replace even property files with db4o.
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
When will DB4O become JDO compliant? The project looks interesting, but corporate adoption won
Posted by: sarish on February 14, 2005 at 10:56 AM
-
Thanks a lot for the blog entry, Joerg!
As to the JDO compliance question:
I think JDO is flawed, especially the querying system. You can read more of my comments on my blog. If the joint spec of EJB and JDO will one day become an acceptable standard, we will certainly support it.
--
Carl Rosenberger
Chief Software Architect
db4objects Inc.
Posted by: carlrosenberger on February 14, 2005 at 11:33 AM
-
If the price for JDO would be the typical enhancement step, parts of the nice simplicity would be lost. The closest-by (with respect to ease-of-use) JDO database I've seen is ObjectDB, but the necessary enhancement has a lot of downsides and in any case destroys this instant-persistence feeling the blog is about.
Posted by: herkules on February 14, 2005 at 01:46 PM
-
Recently I had to come up with a lightweight Java persistence engine and ended up starting a new open-source (LGPL) project:
Meta Attribute Object Store.
It approaches persistence from a different angle - by treating objects as documents being indexed and searched.
Posted by: mgarber on February 15, 2005 at 08:36 AM
|