2 Replies Latest reply on Jan 7, 2002 8:13 AM by Martin Stepanek

    In ejb-jar.xml, is the EJB-QL  unprofitable.

    ma zhenduo Newbie

      all runs well,even if i remove the context of <ejb-ql> in my ejb-jar.xml.
      if only the context of <declared-sql> in jbosscmp-jdbc.xml is useful?
      Another question is that
      i want make the format of paramter is "name" other than "%name%",so i modify the sql to "name like '%{0}%'/where>",but a exception is thrown while calling the finder.how to correct the sql?

      Thank in Advance

      in my ejb-jar.xml
      ---------------------------------------------------

      ..........
      <ejb-ql>
      SELECT OBJECT(m)
      FROM Material m
      WHERE m.name like {0}
      </ejb-ql>

      ---------------------------------------------------
      in my jbosscmp-jdbc.xml
      ---------------------------------------------------

      ......
      <declared-sql>
      name like {0}/where>
      name
      </declared-sql>


        • 1. Re: In ejb-jar.xml, is the EJB-QL  unprofitable.
          Christoph Jäger Newbie

          > ...
          > i want make the format of paramter is "name" other
          > than "%name%",so i modify the sql to "name
          > like '%{0}%'/where>",but a exception is thrown while
          > calling the finder.how to correct the sql?

          Use "...name like '%' || {0} || '%'" (|| is the concatenation for strings in sql).

          Hope to have helped,

          Christoph

          • 2. Re: In ejb-jar.xml, is the EJB-QL  unprofitable.
            Martin Stepanek Newbie

            I need to use LIKE with variable parameter. It was told that EJB QL doesn't support LIKE that way. But I need it desperately. I've read in the manual, that JBoss 3.0 enables to overwrite the EJB-QL query with SQL in another place. But I don't know where exactly to put the SQL, so I can't get it work.

            I've also tried to write the EJB query in following manner:

            SELECT OBJECT(h)
            FROM EBHierarchy h
            WHERE h.path LIKE CONCAT(?1,'%')

            But the JBoss doesn't recognise the CONCAT parameters correctly and creates query like this:

            "SELECT t1_h.id FROM Hierarchy t1_h WHERE t1_h.path LIKE CONCAT"

            What is wrong? If this query can't be formulated in EJB-QL, how can this be eluded?


            Thanx
            Martin