In my project, I am not planning to use Entity Beans. I am going for the DAO approach. But I want the transaction to be managed by the EJB container. But I have a doubt regarding propagation of transaction to DAO from Session bean. Imagine from a session bean's method, businessmethod(), which is declared to be "Required" for it's transaction attribute in ejb-jar.xml, has to call multiple methods on a DAO. The DAO methods encapsulates connection to the database and SQL. I want this multiple method calls on DAO to be atomic (Not through code. Container should do this). Using DAO approach, can I attain this? Or should I use Entity beans (Instead of DAOs) to get container managed transaction? Pleae advice.
U can u se the DAO well. It works fine but in all the methods that u are going to call in the DAO if any ecetion arrises thow the exception, Catch the Exception in EJB( Entity ) and Throw EJBException from EJB. If this happens in any method that u are calling all the transactions happend in the method call will be automatically rolled Back . If not clear revert back babu reddy
Hi Babu, Thank you for the reply. I feel I need to stress the point that I am not planning to use Entity bean. Your statement "Catch the Exception in EJB( Entity ) and Throw EJBException from EJB" forces me to use Entity bean again. I want to avoid this. I am calling DAO methods directly from my Session bean.