2 Replies Latest reply on Feb 5, 2002 10:46 AM by sheepe

    EJB-QL Finders in RH

    sheepe

      First of all, are they implemented in JBoss3? I've been using the not-always-so-fresh cvs snapshots, but they don't seem to work at me.

      What I was trying, is to create a custom finder on a bean (eg. Manufacturer), to return all instances, sorted, based on it's 'name' field. As the first step, I've tried it without sorting, so just a basic EJB-QL query to return everything. I've used the following XDoclet tag:

      @ejb:finder signature="java.util.Collection findSortedAll()" result-type-mapping="Local" query="SELECT DISTINCT OBJECT(o) FROM MANUFACTURER AS o"

      ..which generated the following query into ejb-jar.xml:


      <query-method>
      <method-name>findSortedAll</method-name>
      <method-params></method-params>
      </query-method>
      <result-type-mapping>Local</result-type-mapping>
      <ejb-ql><![CDATA[SELECT DISTINCT OBJECT(o) FROM MANUFACTURER AS o]]



      Trying to deploy this bean, RH says:
      java.lang.NullPointerException
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.(JDBCEJBQLQuery.java:54)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCCommandFactory.createEJBQLQuery(JDBCCommandFactory.java:49)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCQueryManager.start(JDBCQueryManager.java:182)
      ..

        • 1. Re: EJB-QL Finders in RH
          sheepe

          Heh, forum buggered at preview.. so, the main story is above; my questions are:

          1. how to properly define an EJB-QL query to get it actually work, or what do I miss from above? (yes Dain, I have the docs :))

          2. is it any easier / more recommended way to create a findAll() query with sorting, than overwriting the default one?

          tia,
          Christopher

          • 2. Re: EJB-QL Finders in RH
            sheepe

            The EJB-QL query was wrong above.

            Correctly: SELECT OBJECT(m) FROM Manufacturer M

            The plain query works now.. but still, if I add sorting, the name in jbosscmp-jdbc.xml seems to get ignored.