2 Replies Latest reply on Dec 19, 2002 9:49 AM by r_q_d

    Can i generate a dynamic query ejbSelect method using XDocle

    drinferno

      Hi

      I need to retrieve some non-interfaces data, via an ejbSelect method accessed through another ejbHome one. The problem is that the select clause must be a dynamic query. I've found that the @jboss.query tag seems to apply only for finder methods, at class level... What could be the solution?

      Thanks a lot and best regards

        • 1. Re: Can i generate a dynamic query ejbSelect method using XD
          pdutta

          If you are using the latest beta XDoclet (1.2.0beta something) then @jboss.query does work. Here is an example:

          @jboss.query
          signature = "java.util.Set ejbSelectSynamic(java.lang.String sql, java.lang.Object[] args)"
          dynamic = "true"

          Also create the abstract method signature in the bean and off you go. Hope this helps.

          -Partha

          • 2. Re: Can i generate a dynamic query ejbSelect method using XD

            My 2 cents for this used with xdoclet.

            1. define this in the ejb bean:

            * @ejb:finder
            * signature = "java.util.Collection findDynamicly(java.lang.String sql, java.lang.Object[] args)"
            * query = ""
            *
            * @jboss:query
            * signature = "java.util.Collection findDynamicly(java.lang.String sql, java.lang.Object[] args)"
            * dynamic = "true"


            2. at the client side, use this:

            String status=...;

            StringBuffer sql=new StringBuffer("SELECT OBJECT(c) FROM Article as c where c.clientId=?1 and c.status='");

            Vector args=new Vector();
            args.add("123");

            sql.append( status+"'");

            Collection records=home.findDynamicly(sql.toString(), args.toArray());

            hope this helps.