My immediate thought would be to leverage Session's notion of auto
closing after transaction
(org.hibernate.cfg.Settings#isAutoCloseSessionEnabled). That is all
the Synchronization in EntityManagerImpl is doing.
Those hooks are already in place, maybe just add a way for
EntityManager to tell
Scott has verified that the failure he is seeing involves 2 synchronizations.
The first is from EntityManagerImpl and the second is HSearch.
The problem is that the EntityManagerImpl (anonymous)
Synchronization.afterCompletion() closes the session, which in turn, calls
TransactionCoordinatorImp