alistair wrote:
I would do a flush on both sessions. If no exceptions are thrown, all is well. If I get some exceptions, I will try to simulate a rollback by reversing the steps in the transaction logs.
Let's suppose you commited first DS. Then got error commiting second and you're going to rollback by hands first DS. So the data that was commited and maybe already used by someone else will magically disappear. In the worst case, some could have already changed that data so it will be lost forever. This is absolutely inappropriate and it's what XA about.
alistair wrote:
My understanding is that when you call session.flush(), it is persisted to the DB and no explicit tx.rollback() will revert it to the previous state.
No, session.flush() executes SQL statement against DS. if you're in TX calling tx.rollback() will revert the previous state (in fact, state is never changed unless it's commited).
David is right, if you need XA just use DS which supports it.
PS instead of writing hibernate XA emulation for MySQL maybe you can write XA support for MySQL itself?