2 Replies Latest reply on Jul 16, 2002 11:35 PM by dkwong

    Problems found in findAll()

    dkwong Newbie

      Hi All,

      I'm using JBoss 3.0.0, Oracle 8i, CMP 2.0
      I've got some problems in findAll() method.

      (1) The execution SQL select only one field from the table

      2002-07-16 16:35:05,582 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindAllQuery.UserEntityBean.findAll] Executing SQL: SELECT user_id FROM USER

      (2) When I call getUserID() from the Collection, it will auto execute SQL again as follow:

      2002-07-16 16:35:05,627 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.UserEntityBean] Executing SQL: SELECT user_id,user_alias FROM USER WHERE (user_id=?) OR (user_id=?)

      Then, an error occur:
      2002-07-16 16:35:05,642 INFO [STDOUT] User Session Bean Exception Found :java.rmi.NoSuchObjectException: Entity not found: primaryKey=PS.EJB.SAMPLE.USER_ENTITY.UserEntityPK@3e8

      How can I solve these problems?
      (1) Select all fields from table
      (2) getUserID() from collection instead of execute SQL again

      Thanks in advance!!

        • 1. Re: Problems found in findAll()
          razafinimanana Newbie

          To select all field in "findAll" statement you
          have to use "load-groups" and "load-group" features. These
          functions will force JBoss to load all designed fields in
          one time !
          You must modify your "jbosscmp-jdbc.xml" and for each
          Entity bean add something like this:

          <ejb-name>ContractVersion</ejb-name>
          <table-name>CONTRACT_VERSION</table-name>
          <cmp-field>
          <field-name>conComment</field-name>
          </cmp-field>
          .......
          <load-groups>
          <load-group>
          <load-group-name>basic</load-group-name>
          <field-name>conComment</field-name>
          ........
          </load-group>
          </load-groups>

          <query-method>
          <method-name>findAll</method-name>
          <method-params></method-params>
          </query-method>
          <jboss-ql><![CDATA[SELECT OBJECT(o) FROM ContractVersion o]]></jboss-ql>
          <read-ahead>
          on-load
          <page-size>10</page-size>
          <eager-load-group>basic</eager-load-group>
          </read-ahead>



          Hope this can help you ;-)

          Anjarivo RAZAFINIMANANA

          • 2. Re: Problems found in findAll()
            dkwong Newbie

            Thanks! I've edited my jbosscmp-jdbc.xml as follow:

            <table-name>TEST_USER</table-name>
            <cmp-field>
            <field-name>userID</field-name>
            <column-name>user_id</column-name>
            </cmp-field>
            <cmp-field>
            <field-name>userAlias</field-name>
            <column-name>user_alias</column-name>
            </cmp-field>
            <load-groups>
            <load-group>
            <load-group-name>basic</load-group-name>
            <field-name>user_alias</field-name>
            </load-group>
            </load-groups>

            <query-method>
            <method-name>findAll</method-name>
            <method-params></method-params>
            </query-method>
            <jboss-ql>SELECT OBJECT(o) FROM TEST_USER</jboss-ql>
            <read-ahead>
            on-load
            <page-size>10</page-size>
            <eager-load-group>basic</eager-load-group>
            </read-ahead>

            An error Occurs:

            org.jboss.deployment.DeploymentException: error in create of EjbModule: file:/export/home2/JBoss-2.4.4/server/default/deploy/sampleUserEntity.jar; - nested throwable: (org.jboss.deployment.DeploymentException: Unknown query method : public abstract java.util.Collection PS.EJB.SAMPLE.USER_ENTITY.UserEntityHome.findAll() throws java.rmi.RemoteException,javax.ejb.FinderException)

            Would you please help me?

            Many Thx !!