hi all,
I am little bit confused with EJB Transactions.

What I heard is we cannot control transactions in EJB with Connection.setAutoCommint(false) and Connection.commit() and Connection.rollback();

the EJB Container Starts a Transaction , if everything goes well the transaction will be commited otherwise in the catch block we have use SessionContext.setRollbackOnly();

but I am getting different results...

I have Stateless Session Bean, Transaction is Container in managed in ejb-jar.xml and Transaction attribute required.

I am inserting two records in the same table and same database with the same connection object and when I am using SessionContext.setRollbackOnly(); in the catch block and when the second insert is throwing an exception... now the transaction is not getting rolled back i.e. the first record is being inserted.

and when I am controlling it with Connection.setAutocommit(false) and Connection.commit and Connection.rollback() in the catch block it's working fine.
i.e. when second statement throwing some exception the transaction is getting rolled back and when there is no exception the transaction is getting commited.

Does Transactions are managed in differently in different Containers.

I am using OC4J Server.

Last edited by prashantSum; 15Nov2005 at 15:39..