1 Reply Latest reply on Feb 11, 2003 4:05 AM by ABAZIOU

    EJB QL : incomplete  generation of SQL query

    ABAZIOU Newbie

      I'm trying to deploy an entity bean with CMP, but it seems my SQL queries are not correctly generated from EJB SQL.

      I use :
      jboss 3.0.4 with tomcat-4.1.12
      mySQL 3.23.36

      Is it a bug or i missed some configuration ?

      EJB SQL in ejb-jar.xml :

      <query-method>
      <method-name>findAll</method-name>
      <method-params>
      </method-params>
      </query-method>
      <result-type-mapping>Local</result-type-mapping>
      <ejb-ql><![CDATA[select Object(o) from UserBean as o]]></ejb-ql>


      <query-method>
      <method-name>findByEmail</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <result-type-mapping>Local</result-type-mapping>
      <ejb-ql><![CDATA[select Object(o) from UserBean as o where o.email = ?1]]></ejb-ql>


      Begining of bean :
      /**
      * @ejb:bean name="User"
      * jndi-name="jndi/UserBean"
      * type="CMP"
      * cmp-version="2.x"
      *
      * @ejb:pk class = "java.lang.String"
      *
      * @ejb:env-entry name = "DataSourceName" value = "MySqlDS"
      *
      * @ejb:finder
      * signature="Collection findAll()"
      * query="select Object(o) from UserBean as o"
      * result-type-mapping="Local"
      *
      * @ejb:finder
      * signature="User findByEmail(java.lang.String email)"
      * query="select Object(o) from UserBean as o where o.email = ?1"
      * result-type-mapping="Local"
      *
      * @jboss:table-name table-name = "user"
      *
      * @jboss:create-table create = "${jboss.create.table}"
      *
      * @jboss:datasource "MySqlDS"
      *
      *
      **/
      public abstract class UserBean implements EntityBean {

      /**
      * Context set by container
      */
      private javax.ejb.EntityContext _entityContext;

      /**
      * @ejb:persistent-field
      * @ejb:interface-method
      * @ejb:pk-field
      * @jboss:column-name name = "email"
      *
      **/
      public abstract String getEmail();

      /**
      * @ejb:interface-method
      */
      public abstract void setEmail(String email);

      Trace :
      18:44:08,152 ERROR [LogInterceptor] EJBException, causedBy:
      javax.ejb.FinderException: Find failed: java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax near 'FROM userbean t0_o WHERE t0_o.email = 'rick@rickhightower.com'' at line 1
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand.execute(JDBCAbstractQueryCommand.java:148)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCFindEntityCommand.execute(JDBCFindEntityCommand.java:44)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.findEntity(JDBCStoreManager.java:541)
      at org.jboss.ejb.plugins.CMPPersistenceManager.findEntity(CMPPersistenceManager.java:336)