5 Replies Latest reply on Mar 22, 2004 7:05 PM by Stephen Coy

    Does anybody know how to do EJB-QL successfully?

    pouncilt Newbie

      Wassup guys!

      I am using JBoss3.2.3 on windowsXP. I am having a problems with the ejb-ql. I guess Jboss is saying it can't find my method "findByName"described in my ejb-jar.xml.
      Any suggestion would be greatly appreciated.

      Thnanks!


      Here is what my ebj-jar.xml file looks like....


      <ejb-name>CustomerEJB</ejb-name>
      <local-home>com.standardLib.ejb.entityBeans.customer.CustomerHomeLocal</local-home>
      com.standardLib.ejb.entityBeans.customer.CustomerLocal
      <ejb-class>com.standardLib.ejb.entityBeans.customer.CustomerBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>CUSTOMER</abstract-schema-name>
      <cmp-field><field-name>id</field-name></cmp-field>
      <cmp-field><field-name>firstName</field-name></cmp-field>
      <cmp-field><field-name>middleName</field-name></cmp-field>
      <cmp-field><field-name>lastName</field-name></cmp-field>
      <cmp-field><field-name>email</field-name></cmp-field>
      <cmp-field><field-name>userName</field-name></cmp-field>
      <cmp-field><field-name>password</field-name></cmp-field>
      <cmp-field><field-name>type</field-name></cmp-field>
      <primkey-field>id</primkey-field>
      <security-identity><use-caller-identity/></security-identity>


      <query-method>
      <method-name>findByName</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <ejb-ql>
      SELECT OBJECT(C) FROM CUSTOMER AS c
      WHERE c.firstName = ?1 AND c.lastName = ?2
      </ejb-ql>


      <query-method>
      <method-name>ejbSelectCustomers</method-name>
      <method-params/>
      </query-method>
      <ejb-ql>
      SELECT OBJECT(c) FROM CUSTOMER AS c
      </ejb-ql>



      Heres is my CustomerHomeLocal Bean:

      package com.standardLib.ejb.entityBeans.customer;

      import javax.ejb.CreateException;
      import javax.ejb.FinderException;
      import java.util.Collection;

      public interface CustomerHomeLocal extends javax.ejb.EJBLocalHome{
      public CustomerLocal create(CustomerDO user) throws CreateException;
      public CustomerLocal findByPrimaryKey(Integer pk) throws FinderException;
      public CustomerLocal findByName(String firstName, String lastName) throws FinderException;

      // query wrappers for ejbSelects
      public Collection queryCustomers() throws FinderException;

      }

      Here is my error message when I deploy:


      22:21:30,234 INFO [MainDeployer] Starting deployment of package: file:/C:/webpl
      atform/servers/JBoss/jboss-3.2.3/server/default/deploy/customerAppEJBs1.0.jar
      22:21:33,729 INFO [EjbModule] Deploying UserEJB
      22:21:33,789 INFO [EjbModule] Deploying CustomerEJB
      22:21:33,839 INFO [EjbModule] Deploying AddressEJB
      22:21:33,919 INFO [EjbModule] Deploying PhoneEJB
      22:21:33,969 INFO [EjbModule] Deploying CreateAccountEJB
      22:21:35,922 INFO [EntityInstancePool] Started jboss.j2ee:jndiName=UserHomeRemo
      te,plugin=pool,service=EJB
      22:21:35,952 INFO [EntityContainer] Started jboss.j2ee:jndiName=UserHomeRemote,
      service=EJB
      22:21:36,052 INFO [EntityInstancePool] Started jboss.j2ee:jndiName=CustomerHome
      Local,plugin=pool,service=EJB
      22:21:36,082 INFO [EntityContainer] Started jboss.j2ee:jndiName=CustomerHomeLoc
      al,service=EJB
      22:21:36,172 INFO [EntityInstancePool] Started jboss.j2ee:jndiName=AddressHomeL
      ocal,plugin=pool,service=EJB
      22:21:36,202 INFO [EntityContainer] Started jboss.j2ee:jndiName=AddressHomeLoca
      l,service=EJB
      22:21:36,402 INFO [AddressEJB] Table 'ADDRESS' already exists
      22:21:36,533 INFO [PhoneEJB] Table 'PHONE' already exists
      22:21:36,653 INFO [CustomerEJB] Table 'CUSTOMER' already exists
      22:21:36,683 ERROR [EntityContainer] Starting failed
      org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement 'SELE
      CT OBJECT(C) FROM CUSTOMER AS c
      WHERE c.firstName = ?1 AND c.lastName = ?2'; - nested throwable: (java
      .lang.NoSuchMethodError)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCEJBQLQuery.(JDBCEJBQLQuery.j
      ava:50)