I'm pasting the text that I wrote up in the JIRA issue that won't seem to work in case I feel like trying it again later.
I wrote up my original question at
http://forum.hibernate.org/viewtopic.php?p=2246120 but basically once I discovered getCurrentSession(), I went to scrap our JBoss-Hibernate JTA glue code, but the piece that was missing from Hibernate's version is the ability to catch exceptions that are throw from flush() and close(). I'm attaching a patch that lets the user do this. It basically goes like this:
Session session = factory.getCurrentSession();
session.addManagedExceptionHandler(handler);
where the handler just implements the method:
void handleHibernateException(RuntimeException e)
This is needed because when using getCurrentSession(), flushing and closing the session happens outside of any place that the user can wrap in a try block.