Nearly all Java frameworks require complementary integration steps to work appropriately in enterprise applications, ranging from the graphical interface to the database tier. This blog entry by Tim Boudreau takes a look at the Wicket framework, and the database tier -- persistence.
So the problem really was - how can I transparently and easily create IModels for POJOs on demand, keep the database lookup code in one place, and keep session size small. So a framework for doing this started to evolve out of this application. It comes as three libraries: * A persistence facade API - a persistence facade is just an object which manages a POJO's lifecycle. Under the hood, a persistence facade has one of a number of possible lookup strategies - for example, if the object is modified but unsaved, then it will be cached; on the other hand, if it is unmodified, then the lookup strategy used will probably revert to just holding an ID for the object when nothing is interested in it. The persistence facade piece has an SPI (Service Provider Interface) that can be implemented over any database (probably simpler for db4o but certainly doable over hibernate or even using straight JDBC) - the db4o implementation is completely separate. It's basically a matter of implementing two (admittedly complex) interfaces. * An implementation of the persistence facade SPI over db4o * An API that allows you to create Wicket models from a various types of queries, and model classes for modelling a single object or a collection of objects, that do the same kind of property lookup magic, but manage object lifecycle so that the persistence facade ends up in a minimum-size state when it is not actively in use by Wicket components To be clear, the goal was not to create something with magical dynamic proxies or POJOs that transparently get persisted or anything like that; the persistence facade library simply attempts to cleanly express the problem of managing the lifecycle of a persisted object. No magic, it's just a thing you can then build some magic on top of.
Read Tim's complete post : http://weblogs.java.net/blog/timboudreau/archive/2007/11/a_little_persis.html