1 Reply Latest reply on Mar 7, 2002 7:25 PM by dsundstrom

    Can you explain this? Weird behavior when changing a field.

    vpalasi

      Hello.

      I am newbie to JBoss and I am making my first CMP program following the example found at the free volunteer documentation. I use PostgreSQL but this is not important for my question.

      I programmed a Web application "llibre.jar", which manages a database table of Books, the same way as the documentation example, "cd.jar" manage a table of CDs.

      I have also programmed a client ("LLibreClient")which displays the title of the first book in the table. I run this client with help of the following file (named "run.bat"-I am working with Windows)

      set CP= <... here the classpath ...>
      java -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -Djava.naming.provider.url=localhost:1099 -Djava.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces -classpath %CP% CMPBiblio.LlibreClient

      THIS WORKS GREAT but I found a weird behavior and I would like the CMP experts to explain me.

      Let us suppose that the first row of the table contains a book named "Romeo and Juliet" (that is, the contents of its field "title" is "Romeo and Juliet"). When I run the client, the following sentence is displayed on screen:

      First book title: "Romeo and Juliet".

      But, now, I change the field "title" of the first row (from OUTSIDE the program, that is, from PostgreSQL directly, without using the client neither JBoss), to "The Bible". Then, I run again "run.bat" and I get

      First book title: "Romeo and Juliet".

      That is, the program has not become aware about the change of field. I have to restart JBoss in order to get what I want, that is:

      First book title: "The Bible".

      (This problem does not occur if I change the field from the same client, only when I change the field from outside JBoss).

      Is this JBoss normal behavior? I find it extremely weird. Or am I doing something bad?

      Thanks for your help,

      Vicent Palasí

        • 1. Re: Can you explain this? Weird behavior when changing a fie
          dsundstrom

          Entities are cached based on the commit option, which is specified in the jboss.xml file. Commit options are defined in the EJB specification, and if I do remember correctly, JBoss 2.X shipped with commit option A as the default. With commit option A the container assumes it is the sole user of the database. Therefore, the container can cache values between transactions. If you are going to change the values externally, you need to change it to commit option B.