1 Reply Latest reply on Nov 24, 2004 2:44 PM by Johan Borchers

    how to validate the EJB QL

    rajdeep dua Newbie

      I got JBoss DynamicQL working with Xdoclet!!

      Here are changes (from my original posts) I had to do....

      1) Change the declaration of 'searchProducts()' in my ProductBean to 'ejbHomeSearchProducts()'.
      Note case sensitivity. This causes a 'searchProducts()' method to be put in the ProductLocalHome interface
      (er, the @ejb.home-interface tag does).

      That got rid of the 'Warning: Each local home method must match a method...' error msg at deployment.

      2) Change the declaration and use of 'findGeneral()' to 'ejbSelectGeneral()'. Xdoclet appears to be looking for specific
      function name prefixes and handles them accordingly. 'ejbSelect...()' is one of them.

      3) Removed the @ejb.finder signature="java.util.Collection ejbSelectGeneral...' tag in ProductBean.java.
      But I had to leave the @jboss.query signature="java.util.Collection ejbSelectGeneral...' tag in there.

      For some reason, Xdoclet was putting two


      nodes in the ejb-jar.xml file (but only one in the jbosscmp-jdbc.xml file. Just declaring the
      'public abstract Collection ejbSelectGeneral(...)' method in the bean file was enough for Xdoclet to add a single <query...>
      node to ejb-jar.xml.


      Well, not quite. I reeeeeally want to use the SQL LIKE operator with parameters. Guess I need to upgrade to 3.2.6 or 4.0.....

        • 1. Re: how to validate the EJB QL
          Johan Borchers Newbie

          I'm using DynamicQL with a SearchObject (Value Object for searching) the following way. Maybe it gives you a hint for the LIKE. This is working on 3.2.x.

          public abstract Collection ejbSelectGeneric(String jbossQl, Object[] args) throws FinderException;
           * @ejb.home-method
          public Collection ejbHomeGetBySearch(SearchObject so) throws FinderException {
           ArrayList argsList = new ArrayList();
           StringBuffer jbossQl = new StringBuffer();
           jbossQl.append("SELECT OBJECT(t) ");
           jbossQl.append("FROM Table_x t ");
           int bindCount = 0;
           if (so.getNumberCriterion()) {
           jbossQl.append((bindCount == 1 ? "WHERE" : "AND") + " t.column1 LIKE ?" + bindCount + " ");
           if (so.getTitleCriterion()) {
           jbossQl.append((bindCount == 1 ? "WHERE" : "AND") + " t.column2 LIKE ?" + bindCount + " ");
           jbossQl.append("ORDER BY t.column1 ASC");
           Object[] args = argsList.toArray();
           return ejbSelectGeneric(jbossQl.toString(), args);