5 Replies Latest reply on Oct 22, 2002 7:21 PM by adrian.brock

    CMP cache problem

    haowu

      I have a CMP bean and I have a test client. It works fine by itself.

      1. Use client to call findAll. It gets all 5 rows back.
      2. Use MySQL console to remove all 5 rows from the table.
      3. Use client to call findAll. It gets nothing.
      4. Use client to re-create the data. On the first create(), it returns an exception saying -

      java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      java.rmi.ServerException: INSERTING AN ALREADY EXISTING BEAN, ID = 1; nested exception is:
      java.lang.IllegalStateException: INSERTING AN ALREADY EXISTING BEAN, ID = 1


      Is this a bug?

      --Hao

        • 1. Re: CMP cache problem
          haowu

          I'm going to answer my own question.

          The answer lies with the EJB Commit Option. The default cache option is B (for EJB 2.0 CMP). I need to switch to C, if there are external entities (in my case, a MySQL console) update the data.

          I found the default in standardjboss.xml. As with everything else, it can be overwritten in application's jboss.xml.

          --Hao

          • 2. Re: CMP cache problem
            roysun

            What does the "B" and "C" mean?

            Roy

            • 3. Re: CMP cache problem
              haowu

              This is my understanding - check out the EJB spec for confirmation:

              A - exclusive Read/Write, i.e. no one else will read/write the data. This means Read/Write can access the cache, instead of the DB.

              B - exclusive Write, shared Read, i.e. no external updates beside your application. This means Write will go back to DB immediately as there are possible other readers, but Read can pull off cache as no one else is updating.

              C - shared Read/Write. Basically not relying on cache. Write goes into DB immediately, even Read will consume from the database. Basically transaction is the scope of caching.

              --Hao

              • 4. Re: CMP cache problem
                mgl

                Where do I specify these options?

                • 5. Re: CMP cache problem

                  jboss.xml
                  default is in standardjboss.xml

                  see the dtd or free docs for more info

                  Regards,
                  Adrian