Search code examples
jsfjpaejbmanaged-beanjta

Transactions on Managed Beans


Good afternoon in my timezone.

I am working on a WEB application that uses JAVA EE6 , more precisely with JPA, JSF and EJB. In a JSF page i call a method to save data onto database.In the Managed Bean i have the following method :

 @ManagedProperty(value = "#{jndi['ejb/objectEAO']}")
 private ObjectEAO objectEAO;

 public void save(){
      ...
     for(Type1 type : list){
         if(..){
             ....
            objectEAO.save(type);
          }
      }
  } 

My question is: Is the save method transactional by default ? If the third insert fails for some reason , is the all process rollbacked ? The objectEAO is a EJB.

Thanks in advance. Best regards


Solution

  • save() method in EJB bean is transactional (assuming CMT - Container Managed Transactions), not the one in your JSF managed bean. So, if one insert fails it will rollback only that one operation, without impacting previous inserts.