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

    Does anybody know how to do EJB-QL successfully?

    pouncilt

      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)

        • 1. Re: Does anybody know how to do EJB-QL successfully?
          scoy

          Your customer ejb is called CustomerEJB, therefore that is how it must be referenced in the ejb-ql.

          ie. SELECT OBJECT (c) FROM CustomerEJB AS c ...

          Steve Coy

          • 2. Re: Does anybody know how to do EJB-QL successfully?
            pouncilt

            scoy,
            Are you sure about this.... Because when I change my ejb-jar.xml file to what you have suggested, I get an error saying it expects table name to match the abstract schema name. So when I change it back to the way that I originally had it, jboss doesn't complain about the table name.

            Have you got ejb-ql to work for jboss3.2.3? Can you send me some code that worked for you?

            • 3. Re: Does anybody know how to do EJB-QL successfully?
              pouncilt

              I figured out what my problem is. My problem is Jboss doesn't work well with Windows XP so I am going to use Window2000 instead.

              Thanks to everyone who gave a suggestion on how to solve the problem.

              Thanks again!

              tp

              • 4. Re: Does anybody know how to do EJB-QL successfully?
                rafcio

                 

                "pouncil" wrote:
                I figured out what my problem is. My problem is Jboss doesn't work well with Windows XP so I am going to use Window2000 instead.

                Thanks to everyone who gave a suggestion on how to solve the problem.

                Thanks again!

                tp


                JBoss is working fine with Windows XP.


                Rafal

                • 5. Re: Does anybody know how to do EJB-QL successfully?
                  scoy

                   

                  "pouncil" wrote:
                  scoy, Are you sure about this....


                  You could be right - my CMP is a bit rusty at the moment. My first instinct was that there was something wrong with your declarations for the accessors:

                  public abstract String getFirstName();
                  public abstract setFirstName(String n);

                  etc.

                  It's hard to tell because you have not posted the whole class declaration.

                  Steve Coy