I am reading conflicting things about using Hibernate 3 and nested transactions in relation to the default transaction manager. If I have setup a datasource in JBoss that uses the default transaction manager (and it appears to default to the org.hibernate.transaction.JTATransactionFactory) nested transactions do not work for me. This is what I see:
Quote:
org.hibernate.exception.GenericJDBCException: Cannot open connection
If I remove the nesting, then the error goes away. The code looks something like this
Code:
public void method1() {
Session session = ... get session from jndi lookup in JBoss
Transaction transaction = session.beginTransaction();
... do some stuff
method2();
transaction.commit();
}
public void method2() {
Session session = ... get session from jndi lookup in JBoss
Transaction transaction = session.beginTransaction();
... do some stuff
transaction.commit();
}
Now, I WANT the nested transaction to work. If the inner fails (method2) then the outer (method1) should fail as well.
This does not work at all. The only way it works is if I remove the session.beginTransaction() in method1 and therefore remove the nesting.
So I have two questions:
1.) Can I do nested transactions with the default JTA transaction manager.
2.) If not, which transaction manager can I use that will allow me to do this?
Thanks in advance,
Mark