I have a DAO implementation that uses a HibernateTransactionManager for transaction management and the application has 2 session factories. I am getting an exception at the transactionManager.commit() line below. Does performing Hibernate operations within a transaction manager related to a different session factory cause problems?
TransactionStatus status = transactionManager.getTransaction(def);
try{
doHibernateStuff1(); //Does Hibernate stuff with session
//factory related to Tx Manager
doHibernateStuff2(); //Does Hibernate stuff with session
//factory not related to Tx Manager
}
catch(DataAccessException){
transactionManager.rollback(status);
}
transactionManager.commit(status); //Exception happens here.
The exception appears to be trying to perform the operations in doHibernateStuff2();
again in the txManager.commit()
.
If you want to suggest a kludge and/or proper way of dealing with this, I would appreciate it.