3 Replies Latest reply on Sep 17, 2002 4:34 AM by Tarek Kassem

    Transactional integrity problem

    Randy Nolen Newbie

      (This was originally posted on the CMP forum)

      I'm working on an app using jBoss 2-4-3 using CMP entity beans, stateless session beans, and CMT. The application is essentially a shopping cart where the user enters one or more products, one or more payments per product, and submits the order.

      We have single method in a stateless session bean that is called to perform the updates which include adding a record to a transaction table, a record to a payment table, a join table record tying payment to transaction, a trans detail record for each product, and a payment detail record for each payment. It passes the update requests on to additional stateless session beans who have the responsibility of updating their assigned entity bean(s).

      All of the entity and session bean methods are defined as REQUIRED for transactions. What's happening is that a failure in one of the creates is NOT causing ALL of the previous updates to roll back. For example, if the failure occurs while writing the payment detail record, then the updates for the trans detail and the join table are rolled back, but the payment and transaction records are still written putting the database into a bad state.

      Can anyone give me a hint as to what might be our problem here?


        • 1. Re: Transactional integrity problem
          Henning Voss Newbie

          It's a good thing that the set methods in your entity beans require a transaction, but as long as the stateless session bean, that calls for the updates does not handle them all in one transaction, you will get a rollback only on the update that misperformed.

          Two ways to do it:
          Easy way: set the method of your stateless session bean which calls for the updates as required; this causes all the updates to be performed in one transaction.
          Fairly easy way: assign your own user transaction to all the updates within your session bean.

          • 2. Re: Transactional integrity problem
            Randy Nolen Newbie

            Thanks for the reply. Actually the method in the session bean that controls all of the updates also is set to REQUIRES for transactions. As it is the initial point of entry from the client, I would expect that a transaction is created for that method and would be the transaction used for all of the other updates called from that method.

            • 3. Re: Transactional integrity problem
              Tarek Kassem Newbie

              I faced the same problem, and the solution is to define a data source class in the jboss.jcml that implements javax.sql.XADataSource(not the normal jdbc driver class). in my case it was oracle.jdbc.xa.client.OracleXADataSource (for Oracle). becuase your datasource class must support the two phase commit protocol