4 Replies Latest reply on Sep 5, 2003 3:46 AM by gbeutler

    Problems with CMP/DAO Patter

    wellington.pinheiro

      Hello,

      We are developing an application that uses EJB CMP and for the most of queries we are using a DAO Pattern to get the Database Data.

      We have a big process where we are updating many EJB's and just after this update we make a DAO call to get this data that was updated (via EJB) and some other records that were in the DB. The problem is that the data that were just updated is not being retrieved by the DAO.

      I thought it was because the container didn't have made the store of the EJB data...so, I put a message on the ejbStore() and this is what really happens!!! But I need this data just after the EJB update !!!

      Has anybody seen this kind of problem or has a solution for this??

      Thanks,
      Wellington.

        • 1. Re: Problems with CMP/DAO Patter
          raja05

          What is the Transaction Attribute on ur Methods?
          If u have the update/insert and select in the same method and have a "Required" tx attribute, you are not committing the changes as they are in the same method. Change your Tx Attribute or split your insert/update and select into different methods.

          • 2. Re: Problems with CMP/DAO Patter
            wellington.pinheiro

            I'm using one method for update and another for select where the first calls the other. Both methods use a Required transaction and I can't break this transaction!

            • 3. Re: Problems with CMP/DAO Patter
              raja05

              If u have a Stateless bean doing the calls for updates/selects, create a method for updates and make that run with a "RequiresNew" attribute. This way, your updates will be commited (coz of a RequiresNew) and the Select which happens in another method would get the new values. So methodA in SLSB calls update() followed by select() and update() is a RequiresNew method.

              -Raj

              • 4. Re: Problems with CMP/DAO Patter

                Hi,

                I'm running in a similar problem with JBoss 3.2.2RC3 and set the transactual attribute to RequiresNew already. This doesn't work. Is there a known problem?

                best regards,

                Guido