4 Replies Latest reply on Jun 25, 2008 9:30 AM by mail.micke

    Performance issue getter method?

    prasad_k

      Hi everyone,
        Performance bad when getter DAO method call , the methods call 6-7 times to load the data ............
      any suggest me why this is calling many times.........
      i m using seam 2.0.0 and richfaces 3.2.0

        • 1. Re: Performance issue getter method?
          mail.micke

          Hi there


          Did you read my reply to your previous question?

          • 2. Re: Performance issue getter method?
            diegocoronel

            Did you tried a factory ?

            • 3. Re: Performance issue getter method?
              prasad_k

              Hello Mikael Andersson ,
              thank you for hint,
              i read your reply but i not getting the solutions for this, i tried but list not update when any when any event has done.
              please suggest me any other reason. why getter method is calling many times.
              thanks

              • 4. Re: Performance issue getter method?
                mail.micke

                Hi


                You shouldn't put any expensive (datbase lookups for example) in getter methods!


                Instead you can move the loading of the data into a @Create or @Factory annotated method, that will ensure that the data is loaded once.
                In your earlier post you had a @Create annotated method which did the data initialization, BUT you also called the same method from your get method which you shouldn't.


                If you werent using seam, then you would have to do something like this (don't do this unless you have to):


                public List<String> getFooList(){
                  if(fooList == null ){
                    fooList = do.getFooList();
                  }
                  return fooList;
                }
                



                In that way you cache the fooList for the later invocations of the get method.


                Hope this helps a little,
                micke