6 Replies Latest reply on Feb 14, 2003 8:11 PM by guydaniel

    loosing @jboss:finder-query ???

    hanzz

      hi all,

      i just built my first cmp ejb and added some finders like this:

      * @ejb:finder signature="java.util.Collection findAll()"
      *
      * @ejb:finder signature="at.test.interfaces.Company findByName( java.lang.String pName )"
      *
      * @jboss:finder-query name="findByName"
      * query="cmp_name = {0}"
      *
      * @ejb:finder signature="at.test.interfaces.Company findAnotherByName( int pId, java.lang.String pName )"
      *
      * @jboss:finder-query name="findAnotherByName"
      * query="cmpid != {0} AND cmp_name = {1}"


      the build process works fine and everything seems ok but when the bean is deployed to jboss i get the following message:

      16:47:10,549 INFO [EJBDeployer]
      Bean : lbs/Company
      Method : public abstract Company findAnotherByName(int, String) throws RemoteExc
      eption, FinderException
      Section: 10.5.6
      Warning: Every finder method except findByPrimaryKey(key) must be associated wit
      h a query element in the deployment descriptor.

      16:47:10,569 INFO [EJBDeployer]
      Bean : lbs/Company
      Method : public abstract Company findByName(String) throws RemoteException, Find
      erException
      Section: 10.5.6
      Warning: Every finder method except findByPrimaryKey(key) must be associated wit
      h a query element in the deployment descriptor.

      so what does this mean? i did associate a query element (which is represented by the @jboss-finder-query xdoclet tag...)???

      thanks for your help
      hans

        • 1. Re: loosing @jboss:finder-query ???
          lorensrosen

          I'm not sure what's wrong here. But if you just want to get simple queries like these working, you might try using the ejb-ql rather than the jboss-ql.

          The other piece of advice I can give is that xdoclet isn't a perfect abstraction -- sometimes you have to look at the generated files to figure out the problem.

          If you're still stuck attach the code to your bean and I'll take a closer look at it.

          • 2. Re: loosing @jboss:finder-query ???
            guydaniel

            hanzz,

            In case you still need help on this, you have to use the xdoclet merge function to push some EJQL into ejb-jar.xml.

            You have to create an xml finder snippet and name this ejb-finders-{0}.xml, and put it in your "xdoclet merge dir", where "{0}" is your bean name (eg. CustomerBean)

            An example finder query xml snippet:


            <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(d)
            FROM customer d
            WHERE d.name = ?1
            ]]</ejb-ql>


            I don't think xdoclet looks at the comment embedded sql ... although they might fix this if it is a bug ...

            Regards,

            Guy Daniel

            • 3. Re: loosing @jboss:finder-query ???
              guydaniel

              I found a better way, without using merge files:
              * @ejb.finder signature="java.util.Collection findByName( java.lang.String pName )"
              * view-type="local"
              * query="SELECT OBJECT(d) FROM database d WHERE d.name = ?1"
              * result-type-mapping="Local" *
              *
              * @jboss.query signature="java.util.Collection findByName( java.lang.String pName )"
              * query="SELECT OBJECT(d) FROM database d WHERE d.name = ?1"

              • 4. Re: loosing @jboss:finder-query ???
                guydaniel

                Well , I thought it was a better way after looking at ejb-jar.xml, but this does not work.

                I found the only way to make queries work is to stick them in a merge file, or you get a funny jboss error.

                This error seems to be related to the format of the query in ejb-jar.xml. Xdoclet will put the query all on one line in ejb, even if you space it out in the comment.

                If I do this with a merge file :
                <ejb-ql><![CDATA[
                SELECT OBJECT(d)
                FROM database d
                WHERE d.name = ?1
                ]]></ejb-ql>

                it works!

                If I rely on the automatic xdoclet generated query, I get this in ejb-jar.xml:
                <ejb-ql><![CDATA[SELECT OBJECT(d) FROM database d WHERE d.name = ?1]]></ejb-ql>

                and JBoss gives me:

                org.jboss.deployment.DeploymentException: Error compiling ejbql; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException
                : Encountered "SELECT" at line 2, column 13.
                Was expecting one of:

                "AND" ...
                "OR" ...
                )
                at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.(JDBCEJBQLQuery.java:46)


                • 5. Re: loosing @jboss:finder-query ???
                  lafr

                  What version of JBoss do you use ?
                  With JBoss-4.0 I have no problems with this.

                  • 6. Re: loosing @jboss:finder-query ???
                    guydaniel

                    My JBoss version is 3.0.6