2 Replies Latest reply on Oct 6, 2002 7:05 PM by jstrohm

    CMP 2.0 read-ahead and cache problems

    jstrohm

      I running Jboss 3.0.1, PostgreSQL 7.2 (debug driver), trying to do a simple CMP 2.0 entity bean. This is the problem I get:

      It seems that every time I call a get method on the bean (the same get method), it hits the database each time. Is there something you need to do to cache the object?

      I'm using commit option 'A' on all my beans.

      Another things that doesn't seem to work is I can't change any of the read-ahead options. I had seen another post where someone said that it had a bug in it. Has that been fixed?

      ------------------------ jsp snippet

      LocalCustomer customer=customerHome.findByPrimaryKey("10IGFJ");

      // NASP is the primary key
      System.out.println("NASP:");
      System.out.println(" "+customer.getNASP());
      System.out.println(" "+customer.getNASP());
      System.out.println(" "+customer.getNASP());
      System.out.println(" "+customer.getNASP());
      System.out.println(" "+customer.getNASP());

      --------------------------- log snippet
      In the log file I get:

      2002-09-16 16:28:11,711 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.ejb/Customer.findByPrimaryKey] Executing SQL: SELECT nasp FROM customer WHERE nasp=?
      2002-09-16 16:28:11,725 INFO [STDOUT] NASP:
      2002-09-16 16:28:11,729 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.ejb/Customer] Executing SQL: SELECT name FROM customer WHERE (nasp=?)
      2002-09-16 16:28:11,736 INFO [STDOUT] 10IGFJ
      2002-09-16 16:28:11,737 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.ejb/Customer] Executing SQL: SELECT name FROM customer WHERE (nasp=?)
      2002-09-16 16:28:11,742 INFO [STDOUT] 10IGFJ
      2002-09-16 16:28:11,743 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.ejb/Customer] Executing SQL: SELECT name FROM customer WHERE (nasp=?)
      2002-09-16 16:28:11,747 INFO [STDOUT] 10IGFJ
      2002-09-16 16:28:11,749 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.ejb/Customer] Executing SQL: SELECT name FROM customer WHERE (nasp=?)
      2002-09-16 16:28:11,753 INFO [STDOUT] 10IGFJ
      2002-09-16 16:28:11,755 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.ejb/Customer] Executing SQL: SELECT name FROM customer WHERE (nasp=?)
      2002-09-16 16:28:11,762 INFO [STDOUT] 10IGFJ

        • 1. Re: CMP 2.0 read-ahead and cache problems
          dsundstrom

          Did you read chapter 6 of the JBossCMP documentation?

          I suggest you upgrade to Jboss 3.0.2.

          It looks like commit option A is not set (correctly). Read ahead only affects reading of extra (unnecessary colmns) and does not affect caching.

          If you can't get this working post a bug report with a small test case.

          • 2. Re: CMP 2.0 read-ahead and cache problems
            jstrohm

            I figure out what was happening (after a bit more reading). I wasn't in a transaction. When I put it in a transaction it cached everything like I expected it to.