1 Reply Latest reply on Jan 30, 2003 3:39 PM by Mad

    dynamic-ql for many-to-many relationship

    Eddie Fang Newbie

      Hi all:

      I have two beans:
      Activity : ID (primary)
      forOrderID (many-to-many cmr field)
      Order: ID (primary)
      forActivityID (many-to-many cmr field)

      They have a many-to-many relationship between them using foreign-table mapping. When I execute a query using dynamic-ql like so:

      String filter = "";
      String orderBy = "";

      String jbossQL = "SELECT DISTINCT OBJECT(o) FROM activity AS o, IN (o.forOrderID) AS r WHERE r.iD = " + getID() + filter + orderBy;

      (returns all activites belonging to order where the order id = ID)

      I get an error:

      javax.ejb.FinderException: Error compiling ejbql: org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "o.forOrderID" at line 1, column 85.
      Was excepting: <COLLECTION_VALUED_PATH> ...

      When i do a similar query in a one-to-many relatioship, the query works. Why doesn't the query work in a many-to-many relationship?


        • 1. Re: dynamic-ql for many-to-many relationship
          Mad Newbie


          I have a similar problem

          Two beans, this is my relation:


          and this is my query:

          <ejb-ql>SELECT Object(o) FROM NavigationTree AS o, IN (o.areaId) as t, IN (o.languageId) as r WHERE t.areaId = ?1 AND r.languageId = ?2</ejb-ql>

          and I get an error:

          org.jboss.deployment.DeploymentException: Error compiling ejbql; - nested throwable: (org.jboss.ejb.plugins.cmp.ejbql.ParseException: Encountered "o.areaId" atline 1, column 50.
          Was expecting:

          Why doesn't the query don´t work? can you help me?