3 Replies Latest reply on Dec 10, 2003 4:25 AM by Adrian Brock

    How to cache the table?

    xf_fong Newbie

      I want to know how to cache the table?I only know perhaps the <instance-cache> tag will be the clue,but I don't find a good sample! Can anyone give me some links?

      Another thing confused me is when I use findAll() to do do some test. In this case, I modified the Beans setEntityContext as followed:
      ==================================
      public void setEntityContext(EntityContext ctx){
      this.context = ctx;
      System.out.println("setEntityContext exec! -- " + this.context.toString());
      }
      ==================================
      I found when I start 5 clients, the memory consumed will be 5 times as 1 client. And will also produce 5 different context.
      The client codes are simple:
      ============================
      Collection c = signalHome.findAll();
      ============================
      Is that mean 5 clients will produce 5 EJB Object instances and 5 Enterprise Bean instances? Or other kind of understanding?

      (I think EJB Object instance is from my Component Interface: XXX extends EJBObject and Enterprise Bean instance is from my EntityBean: XXXBean implements EntityBean. Am I right?)

        • 1. Re: How to cache the table?
          Adrian Brock Master

          Your first question is unclear.
          I'm guessing the answer is <commit-option>A</commit-option>

          For the second question.
          findAll is executed against the home interface. This requires
          and EntityBean without a primary key.
          Each will load the data for their transaction.

          All finders except findByPrimaryKey bypass the cache.

          Regards,
          Adrian

          • 2. Re: How to cache the table?
            xf_fong Newbie

            My first question is I want to cache the CMP EntityBean to the memory! In detail: Such as if my CMP EntityBean corresponding a 10000 rows table, Can I cache the whole table's data into the memory?I think that will promote the efficiency! I got somebody's answer is POSSIBLE! I think I sure write something in the deployment descriptors(those xml files)! But I don't know how to do that! Can you help me?

            Another question is how can I only cache 5000 rows data of the 10000 row table?

            Thanks!

            • 3. Re: How to cache the table?
              Adrian Brock Master

              This article explains caching, in particular commit-option A
              i mentioned before.
              http://www.onjava.com/pub/a/onjava/2003/05/28/jboss_optimization.html?page=1

              There is nothing to preload a table into memory.
              You would have to extend something in the jboss cmp engine
              to do this.

              You could do it manually, but less efficiently with a findAll
              then a get() on each some field for each primary key.

              Regards,
              Adrian