I am looking at trying to integrate transactions from a third-party framework with hibernate. Assume that the Framework uses JTA (it doesn't, but I can probably implement some basic JTA or JTA-like transaction manager).
In particular, I would like it if a commit from within the framework flushed and committed the hibernate session.
I noticed that Session.connect() and JTATransaction.begin() both register JTA synchronisation callbacks as follows:
Code:
tx.registerSynchronization( new CacheSynchronization(this) )
where tx is an externally obtained javax.transaction.Transaction.
The CacheSynchronization class calls Session.afterTransactionCompletion(). This does a lot of stuff, but appears not to do a flush.
However, if I commit from Hibernate explicitly, it does flush().
So, I am wondering:
1. Why this is (that the synchronisation does not call flush) and if there are any problems with registering a Synchronizer that did flush, and if not, how to do it?
2. On rollback, would I need to call an 'unFlush' method, or would afterTransactionCompletion() clear out the pending requests.
3. If anyone knows of any tutorials on implementing JTA classes for a simple framework. In particular, collaborations between classes.
thanks