2 Replies Latest reply on Nov 22, 2004 10:16 PM by redbeard15

    DynamicQL, Xdoclet, and compile errors

    redbeard15

      I'm running JBoss 3.2.3, Xdoclet 1.2.2 on RedHat 9.

      I have an entity bean that looks like (annotated):

      /**
       * @ejb.bean
       * name="Product"
       * type="CMP"
       * view-type="local"
       * @ejb.finder
       * signature="java.util.Collection findGeneral (java.lang.String id, java.lang.Object[] oarray)"
       * view-type="local"
       * @jboss.query
       * signature="java.util.Collection findGeneral (java.lang.String id, java.lang.Object[] oarray)"
       * dynamic="true"
       */
      public abstract class ProductBean implements EntityBean
      {
       . . . .
       /**
       * @ejb.home-method
       * view-type="local"
       */
       public java.util.Collection findProducts (Hashtable clauses)
       throws FinderException
       {
       StringBuffer jbossQL = new StringBuffer();
       . . . .
       return findGeneral (jbossQL.toString(), args);
       } else {
       throw new FinderException ("No clauses specified");
       }
       }
      }
      


      The 'findProducts()' code is derived from the sample code in the Admin n Development 3.2.X Guide.
      When I run this through XDoclet, the necessary foo seems to be in the 'ejb-jar.xml' and 'jbosscmp-jdbc.xml' - as documented in the Admin n Development guide for 3.2.X.

      Also, the 'ProductLocalHome' interface includes entries for the finder methods:
      public interface ProductLocalHome
       extends javax.ejb.EJBLocalHome
      {
       public java.util.Collection findGeneral (java.lang.String id, java.lang.Objec
      t[] oarray)
       throws javax.ejb.FinderException;
      
       public java.util.Collection findProducts(java.util.Hashtable clauses) throws
      javax.ejb.FinderException;
       . . . .
      }
      


      However, when I compile this, I get the following msg:
       [javac] ProductBean.java:193: cannot resolve symbol
       [javac] symbol : method findGeneral (java.lang.String,java.lang.Object[])
       [javac] location: class com.tm.wineStore.ejb.catalog.ProductBean
       [javac] return findGeneral (jbossQL.toString(), args);
       [javac] ^
       [javac] 1 error
      

      But the 'findGeneral()' method with that signature is the same package as the ProductBean....
      Ideas?

        • 1. Re: DynamicQL, Xdoclet, and compile errors
          redbeard15

          All right, I have the code compiling..... I added the following code to ProductBean.java:

           public abstract java.util.Collection findGeneral (java.lang.String id, Object[] args)
           throws FinderException;
          


          But now I have deployment problems. When I deploy this package, JBoss complains with:
          Method : public abstract Collection findProducts(Hashtable) throws FinderException
          Section: 10.5.6
          Warning: Every finder method except findByPrimaryKey(key) must be associated with a query element in the deployment descriptor.
          


          Sooooo, a 'findxxx()' method is assumed to be a finder method. Okay. If I change 'findProducts()' to 'searchProducts()', as in:
           /**
           * @ejb.home-method
           * view-type="local"
           */
          
           public java.util.Collection searchProducts (Hashtable clauses)
           throws FinderException
           {
           . . . . .
           return findGeneral (jbossQL.toString(), args);
           }
          

          JBoss (at deployment) complains with:
          Method : public abstract Collection searchProducts(Hashtable) throws FinderException
          Section: 12.2.11
          Warning: Each local home method must match a method defined in the entity bean class.
          

          Hmmm. But ProductLocalHome includes a 'public Collection searchProducts()...'
          Ideas?



          • 2. Re: DynamicQL, Xdoclet, and compile errors
            redbeard15

            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

             <query>
             <query-method>
             <method-name>ejbSelectGeneral</method-name>
            

            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.

            Done!

            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.....