2 Replies Latest reply on May 10, 2011 9:57 AM by hugbert

    jboss ql  question

    hugbert

      Hi,

       

      Can I define a EJB finder that uses also another Ejb? Does this make sense at all?

       

      I have EJB's  in different tables and tried a finder like this:

      I want all Objects from WorkflowEntry with an Id that is also in CurrentStep.

       

      SELECT OBJECT(o) FROM WorkflowEntry o WHERE o.state = ?1 AND o.id IN (SELECT CurrentStep step FROM CurrentStep step WHERE step.owner = ?2 AND step.status = ?3)

       

      Maybe the syntax is wrong, but before I go further I would like to know if this is possible at all.

      JBoss does not like my try and says.

       

      org.jboss.deployment.DeploymentException: Error compiling JBossQL statement 'SELECT OBJECT(o) FROM WorkflowEntry o WHERE o.state = ?1 and o.id IN (SELECT CurrentStep step from CurrentStep step where step.owner = ?2 and step.status = ?3)'

      ....

      Caused by: org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "SELECT" at line 1, column 71.

      Was expecting one of:

          "ABS" ...

          "COUNT" ...

           ....

       

      Could anyone please tell me, if this is possible and maybe what I miss?

      Also I would be glad if someone pointed me to a good documentation about this.

       

      Thank you

      Hubert

        • 1. jboss ql  question
          wdfink

          I suppose you are using EJB2.1 CMP because of the query syntax, right?

           

          A sub-select is not possible in this case, you have to use EJB3 (JPA-QL) for this.

          What you can do if you have a relation is something like

           

          SELECT OBJECT(o) FROM WorkflowEntry o, IN (o.currentSteps) step WHERE o.state = ?1 AND step.owner = ?2 AND step.status = ?3

           

          You must have a CMR in this case!

          1 of 1 people found this helpful
          • 2. jboss ql  question
            hugbert

            Wolf-Dieter,

             

            Thank you, that helped me.

            I don't have CMR and yes, this is EJB2.1 CMP.

            I think about a change to EJB3.

             

            Thanks again

            Hubert