3 Replies Latest reply on Sep 25, 2001 3:23 PM by Paul Austin

    ejbStore() question

    Andrejus Chaliapinas Newbie

      Hi, I'm implementing test example in which stateless session bean often calls
      getXXX() methods and rarely setXXX() methods of entity bean. Before any of this call
      session bean calls findByName() to get entity bean reference. Now is my question -
      when I look on server side I could see that after each getXXX() method container
      performs ejbStore() on entity bean. Is it possible somehow to optimize this only
      to setXXX() methods ?

      Thank you,

        • 1. Re: ejbStore() question
          Joseph Fifield Newbie

          JBoss uses a method called isModified to determine if the entity needs to be saved. The default implementation of this simply returns true. Override this method in the bean and only return true when something has been modified. I set it local modified flag to true in all setXXX methods, then set it to false in ejbStore and ejbLoad, and use that as the return value of isModified. You may also have to reset it in ejbActivate, I don't remember...


          • 2. Re: ejbStore() question
            Andrejus Chaliapinas Newbie

            Thanks a lot! Is this a common practice for App Servers? What about WebLogic and WebSphere? Do they have something like this isModified() function?


            • 3. Re: ejbStore() question
              Paul Austin Newbie

              WebLogic does, there is a tag in the weblogic-ejb-jar to tell it which method to use.

              Another thing you should look at doing is define you session been method to have the transaction attribute REQUIRED and the transaction attributes on your entity bean methods to SUPPORTS (which I think is the default). This will then roll back all the changes in the case of errors and also cause ejbStore to only be called at the end of the transaction.