1 Reply Latest reply on Aug 5, 2003 11:53 AM by kutter

    simple EJBQL example not working!

    kutter Newbie

      Hi, All.
      I am quite confused that even simple EJBQL
      examples are not working.

      Can someone please help me?

      I can as well post the code, but its based on the
      standard Gangster example, all infos below.


      (JBoss 3.2.1-tomcat, CMP Gangster Example of 3.2.1 Documentation)

      I try to use a simple CMP field in an EJB query, and I get a
      "org.jboss.deployment.DeploymentException: Error compiling EJB-QL statement
      'SELECT OBJECT(u) FROM gangster u WHERE u.bestFriend = ?1';
      - nested throwable: (java.lang.NullPointerException)"

      Is it not possible to use CMP fields in EJB queries?

      I did this as close to the JBoss 3.2.1 documentation as possible:
      1) added setter/getter for 'bestFriend' to bean,
      2) added declarations to local interface,
      3) added finderdeclaration to local home
      4) added CMP-field and query-definition of finder to ejb-jar.xml

      My query is SELECT OBJECT(u) FROM gangster u WHERE u.bestFriend = ?1
      and I get the Error compiling EJB-QL statement error.

      What do I wrong?

      I add the getter and setter for a new field bestFriend to the GansterBean.java:
      public abstract Gangster getBestFriend();
      public abstract void setBestFriend(Gangster u);

      I add them to the local interface Gangster.java:
      Gangster getBestFriend();
      void setBestFriend(Gangster u);

      I add the CMP-field definition to ejb-jar.xml:

      I add a new finder to the ejb-jar.xml:

      SELECT OBJECT(u) FROM gangster u WHERE u.bestFriend = ?1

      I add the corresponding declaration to the local home interface GanagsterHome.java:

      Collection findBestFriend2(Gangster g) throws FinderException;

        • 1. SOLVED!
          kutter Newbie

          CMP fields pointing to other objects are not
          real relations, one needs to use a 1:1 CMR.

          This leads back to my earlier post that I
          need an example for a 1:1 CMR used in

          Best, Philipp