3 Replies Latest reply on Sep 29, 2003 5:37 PM by Manuel Fehlhammer

    findByDynamicQL

    Michal Kalanski Newbie

      Hello All

      I have source:

      GrupyFacade facade = GrupyFacadeUtil.getHome(p).create();
      Collection browse_collection = new HashSet();
      String polish_string="some polish chars"; //charset windows-1250
      Object[] args={polish_string};
      Object[]args1={};

      String query = "SELECT OBJECT(o) FROM Grupy o WHERE o.nazwa= ?1 ";
      //first call
      browse_collection = facade.findByDynamicQL(query, args);

      query="SELECT OBJECT(o) FROM Grupy o WHERE o.nazwa='"+polish_string+"'";
      //second call
      browse_collection = facade.findByDynamicQL(query, args1);

      When I call findByDynamicQL first time it returns some objects (EJB)

      When I call findByDynamicQL second time it don't find any objects. (when I try to find string without polish chars it working)

      Is it BUG in JBOSS?
      Is it posible to use findByDynamicQL with polish chars in the second call ?

        • 1. Re: findByDynamicQL
          vincentchun Newbie

          Are you use CMP?

          or findByDynamicQL is a BMP method?

          if use CMP, do the following.

          in your ejb-jar.xml, set the ejb-ql like this
          <ejb-ql><![CDATA[SELECT OBJECT(o) FROM Grupy o WHERE o.nazwa= ?1]]></ejb-ql>

          The query is not defined in your program.

          set your jboss.xml & jbosscmp-jdbc.xml

          "When I call findByDynamicQL first time it returns some objects (EJB)"

          What are those objects?

          • 2. Re: findByDynamicQL
            Michal Kalanski Newbie

            I'm use CMP.

            I prepare (define) QL in my program !!!

            1 working example:
            ////////////////////////
            q="select object(o) from tabe where o.x=?1 and o.y=?2";
            arg={new String("polish string"),new String("polish string")};
            findByDynamicQL(q,arg);
            ////////////////////////

            2 not working example:
            ////////////////////////
            q="select object(o) from tabe where o.x='polish string' and o.y='polish string'";
            arg={};
            findByDynamicQL(q,arg);
            /////////////////////////

            In my jbosscmp-jdbc.xml I have:

            <query-method>
            <method-name>findByDynamicQL</method-name>
            <method-params>
            <method-param>java.lang.String</method-param>
            <method-param>java.lang.Object[]</method-param>
            </method-params>
            </query-method>
            <dynamic-ql/>


            When I'm looking in database log from first example I see correct SQL.

            When I'm looking in db log from second example I see sql translated to iso-8859-1 charset and db don't find records.

            • 3. Re: findByDynamicQL
              Manuel Fehlhammer Newbie

              Hi mikala,

              turn on trace for the cmp-engine and take a look at the generated sql-string it is sending to the database - maybe this shows you what's going on.

              To turn on look at your servers log4j.xml - there you see some exampels for enabling tracing of jboss internal classes.
              You have to enable tracing for org.jboss.ejb.plugins.cmp

              cheers,

              Manuel