3 Replies Latest reply on Oct 7, 2002 4:08 AM by Alexey Loubyansky

    stopping ejbStore when no mods with cmp2

    David Ward Newbie

      How can I make ejbStore() not get called on a cmp 2.0 entity bean in JBoss 3.0.1 if no data has changed? With cmp 1.1 beans, the sets/gets weren't abstract so I could keep track of the changes and implement an isModified() method. With cmp 2.0, I can't do that. I'm usually doing just reads (can't make the bean read-only, though, as updates might happen sometimes). I though the jboss cmp container was supposed to keep track of what has changed in cmp 2.0?

      Oh yeah - the reason I don't want ejbStore() called is because I'm using xdoclet to implement soft-locking for me, which introduces a set/getVersion persistent field in my beans. This gets incremented in ejbStore(). The problem is that I don't want it to get incremented if no data in the bean has changed.

      my env:
      - JBoss 3.0.1 w/bundled Jetty
      - Sun JDK 1.4.0_01
      - Red Hat 7.1 Linux 2.4.9-31, i686

      some app info:
      - All entities are cmp 2.0 with only local interfaces behind a single SLSB, with transaction set to Required on all ejbs.
      - I'm using CMR's.

      Thanks for the help,
      David

        • 1. Re: stopping ejbStore when no mods with cmp2
          Chris DeGreef Newbie

          isModified() was the preferred pattern in the previous releases. But the abstract setters in 2.0 prohibit this technique.

          In another thread I noticed that ejbStore is called regardless of the attributes being changed. The comment was that this could be looked at if it presented an efficiency problem. Maybe ejbStore shouldn't be called even if it is fast. Or maybe there should be some boolean that can be checked that is true if any persistent field is modified since last loaded or saved.

          Or perhaps there is an entirely new mechanism that is recommended for version stamping rows in the database.

          Would someone who has made this work or worked around it please respond. Does anyone know how this is accomplished in other servers?

          • 2. Re: stopping ejbStore when no mods with cmp2
            Alexey Loubyansky Master

            AFAIK, current implementation will always call ejbStore. But sql update statement will be executed only in case if some field is "dirty", i.e. changed. If there are no dirty fields it just returns.
            It doesn't help you, though. Optimistic locking is planned in near future.

            • 3. Re: stopping ejbStore when no mods with cmp2
              Alexey Loubyansky Master

              AFAIK, current implementation will always call ejbStore. But sql update statement will be executed only in case if some field is "dirty", i.e. changed. If there are no dirty fields it just returns.
              It doesn't help you, though. Optimistic locking is planned in near future.