Using NeoDatis OODB for unit testing

By nailsandhammers

Related to the previous blog entry about using db4o for unit testing – I have tried an alternative framework NeoDatis, which is a small and simple OODB for Java, Groovy and .NET. The main reason why I started looking for alternatives was the fact that the DB4O GUI tool Object Manager was only available as part of the commercial license and NeoDatis did have simple GUI object browser. That’s not an issue anymore – DB4O OME is available now. The GPL license was another reason. From my perspective and because of the way I am using this framework for unit testing and temporary storage, the LGPL license just makes more sense than the full GPL that DB4O uses.

The migration from DB4O to NeoDatis was very straightforward, the only difference I had to figure out was on querying objects by class:

//db4o version:
ObjectContainer db = Db4o.openFile("CARS.DAT");
ObjectSet results = db.queryByExample(Car.class);
//returns also objects Cabrio, Sedan, Hatchback, ...

//NeoDatis version
ODB odb = ODBFactory.open("CARS.DAT");
CriteriaQuery query = new CriteriaQuery(Car.class);
query.setPolymorphic(true);	//in order to return the subclasses of Car
Objects results = odb.getObjects(query);
//because simple odb.getObjects(Car.class) doesn't return the subclasses of Car,
//it needs to be explicitly set as polymorphic query.

There are probably more differences than that, and even deeper ones when it comes to features, robustness, reliability, support, but I am just trying to find the right tool for my work, not one hammer for everything.
Speaking of which, I am getting more and more convinced that we might be rushing to use the relational databases a bit too much, even when it is not necessary or not really appropriate. The OODBs for storing objects is one alternative option, Amazon SimpleDB, Apache Hadoop, CouchDB or Google’s BigTable are other data storage options with different benefits and applicability.

Leave a Reply