Hi Jeevan,
The JTA transaction of a CMT SB is attached to the
thread.
You can invoke a simple class in the same transactional context (but your class wont be able to interact with your transaction in a simple way).
Your DAO can throw an exception.
If your EJB doesn't catch it, the container will:
- log the exception.
- rollback the transaction.
- discard the bean instance.
Your EJB can catch it and do a setRollbackOnly on the transaction.
Without exception or setRollbackOnly, the container will commit the transaction automatically when the method of your EJB returns.
If you try to do a commit or a rollback on a Container Managed Transaction, you'll get an exception.
I understand that you don't want to use EntityBeans but if you have access to Java 1.5 in your application, why don't you implement your DAO as a Stateless SessionBean and use JPA for your database interactions ?
That way, you can control your transaction in every layers and even include the database commit/rollback in the same transactional context.
Beno�t