4 Replies Latest reply on Aug 14, 2003 2:31 PM by wellington.pinheiro

    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
          duncan

          Is it possible that you are using two different connections from a connection pool and the first connection has not committed so the second connection cannot read the data from the first connection?

          • 2. Re: Problems with CMP/DAO Patter
            bkross

            I believe the issue has to do with optimistic or pessimistic concurrency and in your case it must be using optimistic concurrency.

            With optimisitic concurrency, the data is not stored until the transaction completes which is why the dao cannot read the data saved via EJB.

            With pessimistic concurrency, the transaction is started as soon as the first EJB stores its data.

            I have only come across this scenario using a different J2EE server as JBoss has not had optimistic concurrency until lately.

            Which version of JBoss are you using?

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

              Hi, it might be possible but I don't know how to test it's really happening!

              I don't know if the container uses the same connection for the persistence of the CMP and the JDBC connection when everything is happening at the same transaction!

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

                I'm using jboss 3.0.3

                Is there any way to force a CMP Entity Bean to store the data? Or some kind of time out?

                Thanks!!