3 Replies Latest reply on Feb 18, 2009 2:35 PM by Gregory Nikle

    How to rollback transaction in Seam?

    Gregory Nikle Apprentice

      Can anybody tell me how to rollback transaction in Seam?

      I use:

           <persistence-unit name="SGUniAdmDatabase" transaction-type="JTA">
                          <property name="dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
                         <!-- These are the default for JBoss EJB3, but not for HEM: -->
                         <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
                         <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
                         <property name="hibernate.cache.use_second_level_cache" value="true" /> 
                       <property name="hibernate.cache.use_query_cache" value="true"/>
                       <property name="hibernate.cache.region_prefix" value="hibernate.test"/>
                         <property name="hibernate.cache.use_minimal_puts" value="true"/>
                          <property name="hibernate.cache.use_structured_entries" value="true"/>
                       <property name="hibernate.jdbc.use_streams_for_binary" value="true"/>
                               <property name="hibernate.generate_statistics" value="false"/>
                               <property name="hibernate.connection.isolation" value="4"/>   -->
                          <!-- <property name="hibernate.show_sql" value="true"/> -->
                          <!-- <property name="hibernate.hbm2ddl.auto" value="create"/>  -->                    
                          <property name="hibernate.transaction.manager_lookup_class" 
                          <property name="jboss.entity.manager.factory.jndi.name" 
                                    value="java:/SGUniAdmEntityManagerFactory" />


           private EntityManager sguniAdm;    

      here is try block:

      try {
      ....some error
      } catch (Exception e) {

        • 1. Re: How to rollback transaction in Seam?
          Binesh Gummadi Novice

          You can throw an @ApplicationException with rollback set to true and handle the exception in pages.xml. May be display the same page with error message.

          • 2. Re: How to rollback transaction in Seam?
            Gregory Nikle Apprentice

            I read about rollingback exceptions and found some example in Seam blog example.

            Can u point or correct me is that right?
            In my source code, I've got lot of sub methods/classes and need to service that and keep atomic transaction.

            This is my exception.

            import javax.ejb.ApplicationException;
            import javax.servlet.http.HttpServletResponse;
            import org.jboss.seam.annotations.exception.HttpError;
            public class SGUniUncheckedException extends Exception {
                 SGUniUncheckedException(String id) {

            In my case, I don't want to show user that error is thrown or any, and I don't think adding to pages.xml anythink is necessary.

            and my app method

            private void partOne() {
               try {
                   //do somethink on DB
               } catch (SGUniUncheckedException e) {
                   throw e;

            upper method which will rollback exception;

            public void mainMethod() {
                try {
                    ///do somethink
                } catch (SGUniUncheckedException e) {
                    throw e;

            • 3. Re: How to rollback transaction in Seam?
              Gregory Nikle Apprentice

              Can anybody help me with that problem, or show own source code to point on right way?
              Please for help