A personal favourite of mine at the moment, is to have a data object for all your domain objects which you then extend so you can add any additional functionality. This is handy because it means you can regenerate your hibernate objects from the database when you need to make schema changes without loosing any custom code you might of written for your domain objects.
With regards to the DAO layer -- I choose to have a <TableName>DAO Interface which extends a HibernateDAOMethods<<TableName>> Interface (this has all the standard methods from HibernateDaoSupport), a <TableName>DAOBaseHibernate which extends Spring's HibernateDaoSupport, and then finally a <TableName>DAOHibernate class that extends my <TableName>DAOBaseHibernate and implements my <TableName>DAO Interface.
It sounds complicated but it's actually quite nice. What I means is that you can keep your auto generated DAOBaseHibernate separated from any custom code you write, again handy if you do a regen from your database after schema changes.
I’m using this pattern for my Job that I’ve been working on for the past year and it works really well. I’ve also recently adopted it for a new project I’m working on for my own personal interest.
Hope that helps.
|