I recently read Kate Pugh’s How to Avoid Writing Code on using Template Toolkit, one of my all time favorite technologies, with Class::DBI [cpan], a technology I have by turns avoided and been intrigued by. And it was enough to make a believer out of me, or at least move “look at Class::DBI” quickly up the todo list.

For rapid prototyping Class::DBI seems to win hands down. I haven’t played with it enough to find its quirks, limitations and oddities. I’m sure they are there, but that comes with the territory with object-relational mappers. But the simple create, retrieve, update, delete looks sweet.

However I’m a little unclear on how it integrates with larger projects, perhaps projects with more abstraction. This could be simply because all the examples are very trivial, or it could be because that is what Class::DBI is suited for.

My instinct is that rather then using Class::DBI to implement your core model, you could use it to implement a set of object peers responsible for marshaling the data into and out of the database.

Also what work (if any) has been done on adding hooks for transparent caching? Your O-R mapper is often the ideal place to maintain a cache of objects (either in memory, or in the filesystem) that result from expensive queries.

Does anyone know of a good example of Class::DBI being used with a moderately complex object hierarchy (one with inheritance) and moderately complex SQL requirements that are perhaps outside of the CRUD basics that Class::DBI nails so well?