Hibernate version:
3.0
Name and version of the database you are using:
SQL Server 2000
Code between sessionFactory.openSession() and session.close():
Code:
//reportSessionFactory points to Report database.
//transactionSessionFactory points to Business database.
reportSession = reportSessionFactory.openSession();
transactionSession = transactionSessionFactory.openSession();
reportSession.beginTransaction();
transactionSession.beginTransaction();
try
{
reportSession.saveOrUpdate(aReportEntity);
transactionSession.update(aTransactionEntity);
reportSession.commit();
transactionSession.commit();
}
catch (Exception)
{
reportSession.rollback();
transactionSession.rollback();
}
finally
{
if (reportSession != null) reportSession.close();
if (transactionSession != null) transactionSession.close();
}
Hi all,
One of our case is to save/update records in tables that reside in more than 1 database, but it also has to be done in transactional manner.
From our snippet above reportSession & transactionSession point to different database.
Although still don't guarantee atomicity, above codes are so far the best we can come up with.
Also, in production we don't run our code in any J2EE environment but in a standalone J2SE.
Any help would be greatly appreciated.
Best Regards,
Setya