In our applications we use JDK-1.4.2, Hibernate 3.1.2 and jboss 4.0.2. Hibernate is configured to join the transactions of the EJB container in which it runs. The DAO's are executed in SessionBeans. In my DAO methods I have catch statements that catch all HibernateExceptions. In this catch block I want to translate the Hibernate exceptions to our own exceptions. But when the DAO runs in a container managed transaction the commit is never executed untill the end of the method of the session bean that is calling the DAO. So HibernateExceptions are thrown in the proxy of the EJB. I cannot translate HibernateExceptions untill control is returned to the delegate of the client that calls the SessionBean. This is far from ideal.
Is there a better place to handle the translation, maybe a jboss extension point?
Or another solution.
An interceptor in JBoss is a possible solution.