4 Replies Latest reply on Jul 21, 2002 1:02 AM by rollc

    ejb-ql w/ cmr-field question

    rollc

      Hi gang,

      I've become quite comfortable now doing ejb-ql with straight cmp-fields, however, am needing some help in the cmr area. No problems on the one side of cmr relationships, it's the many I need some aid in. I've tried scouring the forum, and I even bought Dain's doc -- :)

      Let us say I have an order bean with the following xdoclet specified ejb-ql query:

      @ejb:finder signature="java.util.Collection findByLineItemId(java.lang.Integer lineItemId)"
      query="SELECT OBJECT(o) FROM Orders o, WHERE o.lineitem = ?1"

      lineitem is a cmr-field on the many side of the cmr relationship where Orders is the relationship-role-source. The generated ejb-jar.xml looks good. I can attach if this helps, but I'm certain this is just a fundamental misunderstanding on my part on how to query cmr-fields in ejb-ql.

      Although the this seemingly looks correct to myself, I am encountered with this error:

      21:43:03,343 ERROR [EjbModule] Starting failed
      org.jboss.deployment.DeploymentException: Error compiling ejbql; - nested throwa
      ble: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "" at lin
      e 1, column 54.
      Was expecting one of:
      "IN" ...
      <ABSTRACT_SCHEMA> ...
      )
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.(JDBCEJBQLQuery.j
      ava:46)....

      I've specified my abstract schema as being Orders. I'm looking for any guidance here. Thanks.

      rc

      PS - I've gotten the latest xdoclet from cvs which is supposed to provide jbossql support. Anyone have any strong feelings against using xdoclet as descriptor and interface generator? I've read in many places that this is bad practice.

        • 1. Repost: ejb-ql w/ cmr-field question
          rollc

          I'm only reposting b/c my initial post did not garner a response. If you have any suggestions, or if this post requires additional information, please do not hesitate to reply.

          Thanks,
          RC

          • 2. Re: ejb-ql w/ cmr-field question
            rollc

            It seems as though my syntax for single_valued_navigation was incorrect. Having taken a closer look at the BNF it seems as though it should have read like this instead:

            @ejb:finder signature="java.util.Collection findByLineItemId(java.lang.Integer lineItemId)"
            query="SELECT OBJECT(o) FROM Orders o, WHERE o.lineitem.id = ?1"

            My problem was that I was thinking in SQL rather than EJB-QL. HTH someone else starting out with EJB-QL!

            • 3. Re: ejb-ql w/ cmr-field question
              dsundstrom

              The problem is you have a comma between the end of the FROM clause and the start of the WHERE clause.

              • 4. Re: ejb-ql w/ cmr-field question
                rollc

                Yes, thanks Dain for correcting my previous post. This was a paste error on my part. In addition to the comma I wasn't specifiying the path correctly for the cmr-field.