3 Replies Latest reply on Apr 6, 2005 6:24 PM by Mike Sowka

    Trouble with a simple query method

    Mike Sowka Newbie

      Hello Folks,

      I'm trying to implement a simple query method in a small EJB component of the "Petstore" app.

      #1 I've got an 'public abstract int ejbHomeOrderCount()' in my OrderEJB.java

      #2 I've got an 'int orderCount()' in my OrderLocalHome.java

      #3 I've stuck the following into my ejb-jar.xml:
      ... <cmp-field>s ...
      < query> (without the space here it doesn't show up on the forum :) haha)
      <ejb-ql>SELECT COUNT(o) FROM Order o</ejb-ql>
      < /query>

      JBoss (that rat! ;) ) keeps complaining in an onslaught of errors about:
      org.jboss.deployment.DeploymentException: Query method not found: ejbHomeOrderCount()

      ARGH!!! It's there!

      Any help/suggestions are much appreciated. Thanks,

        • 1. Re: Trouble with a simple query method
          Mike Sowka Newbie

          Well, I've fiddled around with my EJB, separating the orderCount into an ejbHomeOrderCount and ejbSelectOrderCount. I assume that this is the correct (and only) way to do it in the first place.

          ... but now I've got a different error:

          org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement 'SELECT COUNT(o) FROM Order o'; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "Order" at line 1, column 22.

          I've seen this pop up before but it "spontaneously" dissapeared. I've looked into it, and I know my ejb-ql syntax is right as I also found it right in the EJB 2.1 _Spec_ (
          SELECT COUNT(o) FROM Order o

          If You look at my previous post You'll not that I have an abstract-schema Order defined.

          The joys of 'doing' EJBs... aaahhhh

          • 2. Re: Trouble with a simple query method
            Mike Sowka Newbie

            In continueing my monologue on this forum ;) :

            Seeing as the parser is case unsensitive, it turns out "Order" is a reserved identifier. To the best of my knowldege all things SQL related are case unsensitive... I've got a nagging want to send those EJB Spec authors a little note, that _EXACT_ query is in the spec!

            • 3. Re: Trouble with a simple query method
              Mike Sowka Newbie

              Linda DeMichiel has promptly replied to me on what I thought was an error in the spec... it turns out that it's JBoss that seems to have a bug.

              Using Order for an <abstract-schema> is ok, but not for a identifier.

              Reporting a bug.