1 Reply Latest reply on Sep 20, 2012 2:35 AM by Frank Langelage

    TransactionAttribute,jpa,in as 7

    tianheng shi Newbie

      <persistence-unit name="Process" transaction-type="JTA">

                          <jta-data-source>java:jboss/datasources/orcl</jta-data-source>

                          <class>...</class>

                          <!--不包括没有列出来的类-->

                          <exclude-unlisted-classes>true</exclude-unlisted-classes>

                          <properties>

                                    <property name="hibernate.show_sql" value="true" />

                                    <property name="hibernate.hbm2ddl.auto" value="none" />

                                    <property name=" hibernate.jdbc.batch_size" value="100" />

                          </properties>

                </persistence-unit>

      </persistence>

       

      the StatelessBean

      @TransactionManagement(TransactionManagementType.CONTAINER)

      public class BatchService implements BatchServiceRemote,BatchServiceLocal {

           @TransactionAttribute(TransactionAttributeType.NEVER)

          method A(){

       

           B();

          }

            @TransactionAttribute(TransactionAttributeType.MANDATORY)

           method B(){

          }

      ...

      }

       

      I call A(); but method B didnot throw a exception

        • 1. Re: TransactionAttribute,jpa,in as 7
          Frank Langelage Master

          It does not, because calling it this way is a simple Java method call, not the call of the EJB business method.

           

          Introduce another instance of the bean in itself and use this to call business method B.

           

          @TransactionManagement(TransactionManagementType.CONTAINER)

          public class BatchService implements BatchServiceRemote,BatchServiceLocal {

               @EJB BatchServiceLocal service2;

           

               @TransactionAttribute(TransactionAttributeType.NEVER)

              method A(){

               service2.B();

              }

                @TransactionAttribute(TransactionAttributeType.MANDATORY)

               method B(){

              }

          ...

          }