I’ve the JBoss and Hibernate based system.
And I need to process two long operations. Operations can be probably longer than transaction’s timeout.
It operations are persists many-many entities, in two different transactions.
And if something goes wrong, during this operations, I should rollback all changes of the transactions.
What’s the best way to resolve it?
I think, the best way is merge all operations to one transaction, but it requires to set LOng transaction timeout, and it unacceptable for our system.
Is the managing of many transactions better in this situation. And how can I do it?
Can you use a JTA server (transaction coordinator) to do the transaction in multiple steps with XA transactions? This posting has a bit of fan-out to a couple of open-source ones that might work for you.
XA transactions allow you to do a bunch of smaller operations and commit or roll back them in one hit. Try googling for ‘hibernate xa transactions’. Most modern RDBMS platforms (MySQL 5.x, PostgreSQL, SQL Server, Oracle, DB2, Sybase etc.) support XA transactions.