4 Replies Latest reply on Oct 24, 2003 6:30 AM by Ronan-Yann Lorin

    findByPrimaryKey with read-ahead does not work as expected

    Ronan-Yann Lorin Newbie

      At least it does not work as I expect with JBoss-3.2.2!

      I'm trying to optimise database calls for a CMP entity bean.

      For this, I use the "Standard CMP 2.x EntityBean with cache invalidation" container (with commit option A) to get cache working. This works.

      I'd like to have my findByPrimaryKey method fetch all the bean's properties.

      I added a read-ahead tag to my entity bean section of jbosscmp-jdbc.xml. The findByPrimaryKey method select all my bean properties but an other SELECT call is made when my bean is created, I expected to get data from the first call been used!

      Here is the trace:
      11:14:43,406 DEBUG [LoanHabilitation#findByPrimaryKey] Executing SQL: SELECT agf, sofinco, habit, inconnu FROM scoring.TRANSC WHERE agf=?
      11:14:43,468 DEBUG [LoanHabilitation] Executing SQL: SELECT sofinco, habit, inconnu FROM scoring.TRANSC WHERE (agf=?)

      BTW: can somebody tell me how to activate read-ahead for findByPrimaryKey only, in my case I activated it for the entire entity bean.

      Thanks in advance for your help.

        • 1. Re: findByPrimaryKey with read-ahead does not work as expect
          Ivan O. Parra Novice

          Which 3.2.2 are you using, the latest 3.2.2rc4? Try against that version and see what happens.

          I recall making this work and saw the invalidation work across a cluster. Perhaps some more details will show up.

          To confirm, you are running with:
          CMP 2.x with cache invalidation
          Commit A
          no row-locking

          As far as on-find per method:
          Have you tried adding a read-ahead under the section to your jboss.xml findByPrimaryKey? The dtd says this:

          <!ELEMENT query (description?, query-method,
          (jboss-ql | dynamic-ql | declared-sql)?, read-ahead?)>

          <!ELEMENT query-method (method-name, method-params)>

          I don't recall if findByPK is handle by a special call, it may or may not? There's only a few ways to find out.

          Good Luck.

          • 2. Re: findByPrimaryKey with read-ahead does not work as expect
            Horia Muntean Newbie

            Are you calling the entity bean remotely? If the answer is yes, then this is expected since findByPk is in one TX and the business call is in another. Try to use session-facade pattern.

            What stategy are you using for read-ahead(on-find or on-load)?


            • 3. Re: findByPrimaryKey with read-ahead does not work as expect
              Ronan-Yann Lorin Newbie


              The caller and the callee are in the same VM. The caller is a Web Application (war) calling the EJB.

              I use read-ahead on-find straregy:


              • 4. Re: findByPrimaryKey with read-ahead does not work as expect
                Ronan-Yann Lorin Newbie

                Hi and Thanks for your help,

                I use the stable 3.2.2:
                Release ID: JBoss [WonderLand] 3.2.2 (build: CVSTag=JBoss_3_2_2 date=200310182216)

                I use the following container:
                <configuration-name>Standard CMP 2.x EntityBean with cache invalidation</configuration-name>

                which have it's default configuration with:

                I use read-ahead with on-find strategy.
                I have no row-locking specified (the default is supposed to be false).

                I tryed to had the following query tag to my jboss.xml file:


                but this does not activated read-ahead!

                I tried to put it in my jbosscmp-jdbc.xml file and got the following exeption:
                org.jboss.deployment.DeploymentException: Unknown query method : public abstract com.banqueagf.business.interfaces.LoanHabilitation com.banqueagf.business.interfaces.LoanHabilitationHome.findByPrimaryKey(com.banqueagf.business.interfaces.LoanHabilitationPK) throws java.rmi.RemoteException,javax.ejb.FinderException

                anything else I should check or try?