Prevayler

20 Jan

I decided to start my own little project for capturing and displaying diary entries (MovableType is much better but this was more of an experiment than a serious development effort). Rather than worry about database persistence I decided to try out Prevayler – a free software prevalance layer for Java that touts query speeds of up to 9000 times faster than querying an Oracle DB through JDBC. Performance gains aside, the thing I like about Prevayler, as a light-weight prevalance layer, is that you’re not trying to wrap a relational query in an object-oriented way. Your queries are object-oriented. Granted, the persistence (which is done an regular intervals and allows roll-backs) is done via serialization, but since you’d never use such a thing for mass storage, there shouldn’t be any troubles.

It’s very easy to get started. You pretty much drop the jar file in, use the PrevalanceFactory to create a Prevayler object, giving it whatever object encapsulates your data to be persisted, create instances of the Query and Transaction interfaces, write a facade to run these queries and away you go. It really isn’t much to get started – you don’t even need to configure anything to get it working. Your domain objects are simple POJOs (and since you’re controlling where and how they are persisted, you don’t even need accessor methods) – of course implementing Serializable. One of the cool things about Prevayler (though not a driver for using it vs. relational DB) is how easy it is to write integration / functional tests. No worrying about sql exceptions, or connections, etc. Nice and clean.

Now, if I could just find a really good use for it (as opposed to the many free and not-so-free databases and persistence layers out there)… 

Facebook Twitter Email

Comments are closed.