1 Reply Latest reply on Sep 23, 2003 12:36 PM by ioparra

    findByXXX method causes ejb spec violation

    mortena

      I'm using JBoss 3.2.1 and tryes to use the automatic JBoss feature, that makes it possible to implement a finder method only by writing a findByXXX method in the remote and local home's.

      Here is what i've done:

      added the method:

      Collection findByName(String name) throws EJBException, RemoteException, FinderException;

      to the remote home and

      Collection findByName(String name) throws EJBException, FinderException;

      to the local home.
      These methods should return the elements where the "name" property name equals the input parameter.

      This causes an error on deployment:

      Method : public abstract Collection findByName(String) throws EJBException, Remo
      teException, FinderException
      Section: 10.5.6
      Warning: Every finder method except findByPrimaryKey(key) must be associated with a query element in the deployment descriptor.


      Why is that? Must I implement the method myself?

      Thanks

      Morten Andersen

        • 1. Re: findByXXX method causes ejb spec violation
          ioparra

          you need to specify the findQL in your descriptors.

          In your ejb-jar.xml, after your cmp-field/primkey-field, add a query like this:

          <cmp-field>...</cmp-field>
          <primkey-field>..</primkey-field>

          <query-method>
          <method-name>findByName</method-name>
          <method-params>
          <method-param>
          java.lang.String
          </method-param>
          </method-params>
          </query-method>
          <ejb-ql><![CDATA[SELECT OBJECT(barl) from foo as bar where bar.name=?1]]></ejb-ql>


          See if that works.

          -Ivan