I'm trying to develop a pattern for transparent persistence in web applications. At the moment I'm using Struts and Hibernate to develop the application and Xdoclet to create descriptors.
Whilst it works well, I still seem to be wasting a lot of time writing the same type of code, to locate a DAO and persist the bean. I'd like to be able to devise a method of implementing transparent persistence, in the most
painless way possible.
I have been considering using Aspectj (http://www.aspectj.org
) to manipulate the beans to insert the callbacks that are needed inform the bean that it
needs to be persisted. The problem is deciding where I should put the callbacks, i.e. when the bean is finalized it could sync itself with the database (I'm only using this as an example - I don't want to implement it like this). Perhaps I should modify the constructor with an aspect which registers it with a listener that will handle the persistence when the correct callback is made?
Note - I am sort of thinking out loud, what I want is to create a very simple pattern for this and not get bogged down in creating a JBoss 4 style AOP/CMP style framework!
Any advice would be greatly appreciated.