5 Replies Latest reply on Nov 15, 2004 2:03 PM by jaime

    Why an ejbLoad() call for each get* method?

    ricardovm

      I'm writing an entity bean called from a session bean. For teste only, I do:

      ctx.getUserTransaction().begin();
      TestLocal t = home.findByPrimaryKey(id);

      String str_field = t.getStringField();
      Integer int_field = t.getIntegerField();

      t.setStringField("New Value");
      t.setIntegerField(new Integer(123));

      ctx.getUserTransaction().commit();

      And I see in the logs two calls to ejbLoad() and one to ejbStore().

      In my application, I need to do 70 get* calls (for different table fields), and these calls to ejbLoad() are slowing my application.

      Can anyone help me?

        • 1. Re: Why an ejbLoad() call for each get* method?
          dannyb23

          You probably need to update to commit option A etc...
          in the default commit option, you application server does not assume he is the only one touching the database therefore with every "get" you perform your app server refreshes itself from the database in case anyone else updated the database.

          • 2. Re: Why an ejbLoad() call for each get* method?
            ricardovm

             

            "dannyb23" wrote:
            You probably need to update to commit option A etc...
            in the default commit option, you application server does not assume he is the only one touching the database therefore with every "get" you perform your app server refreshes itself from the database in case anyone else updated the database.


            How do I do this in JBoss?

            Thank you,

            Ricardo

            • 3. Re: Why an ejbLoad() call for each get* method?
              laliluna

              First I have a different proposal. Use a ValueObject design pattern instead of calling all the getters. This is only one getter and you get a class representing your entity class. Change the class and send it back.

              You can find the commit Options in
              jboss-3.2.5\server\default\conf\standardjboss.xml

              Kind Regards

              Sebastian

              • 4. Re: Why an ejbLoad() call for each get* method?
                schmidts

                 

                "ricardovm" wrote:

                ...
                ctx.getUserTransaction().begin();
                TestLocal t = home.findByPrimaryKey(id);
                ...


                "LaLiLuna" wrote:
                First I have a different proposal. Use a ValueObject design pattern instead of calling all the getters. This is only one getter and you get a class representing your entity class. Change the class and send it back.


                ricardovm's code seems to access the entity bean by its local interface.
                guess, the value object design pattern won't help.

                • 5. Re: Why an ejbLoad() call for each get* method?
                  jaime

                  A Session Facade + Value Object design patterns solves this problem

                  JaimeS