You have to do your own exception handling. If you're happy with unchecked exceptions reaching the top level of your app, then just catch them there. There are plenty of subclasses of HibernateException to help you figure out what has gone wrong so that you can report interesting details to the user. And of course, you can catch those exceptions lower down in your data access layer and wrap them with application-specific exceptions. This would be my recommendation, as it has the added bonus of hiding hibernate-specific classes from your app.
For the two transactions in a request case: there's no problem if the second transaction aborts, as you've already committed the first transaciton and its changes are already in the database. If the first transaction aborts, you should catch the exception, log it, clear/close your session, and start a new session. Then continue on to your second transaction as normal.
|