0 Replies Latest reply on Nov 22, 2002 6:21 AM by Alexandre Touret

    Newbie: MySQL CMP findAll throws SQLException

    Alexandre Touret Newbie

      Hi,
      I am testing EJBQL finders with JBOSS 3.0.4 and MySQL
      I use XDOCLET for generate interfaces et configuration files.

      The deployment seems to be OK (JAR file in $JBOSS_HOME/server/default)

      When I call the findAll method, the request sended to MYSQL doesn t have the select clause.Then I catch the following exception:

      ERROR [main] (EJBCMPUserTest.java:111) - org.samples.testcase.EJBCMPUserTest.testFindByName():Find failed: java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM utilisateur' at line 1
      javax.ejb.FinderException: Find failed: java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM utilisateur' at line 1
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractQueryCommand.execute(JDBCAbstractQueryCommand.java:148)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCFindEntitiesCommand.execute(JDBCFindEntitiesCommand.java:40)


      I tryed everything with the parameters of my EJB, but every time I have the same exception.

      That s my configuration:


      /**
      * File: EJBCMPUser.java
      * Package: org.samples.ejb
      * Project: J2SEE_Samples
      * EJB entity CMP.
      * Dexcripteurs necessaires a XDOCLET pr generer les classes et descripteurs de deploiement
      * @ejb:bean name="CMPUser"
      * display-name="Test d une recherche d utilisateur par un EJB entity CMP"
      * type="CMP"
      * local-jndi-name="ejb/usercmp_local"
      * jndi-name="ejb/usercmp"
      * view-type="both"
      * cmp-version="2.x"
      * schema="CMPUser"
      *
      * @ejb:interface generate="local,remote"
      * @ejb:home generate="local,remote"
      * @ejb:transaction type="Required"
      *
      * @ejb:finder signature="java.util.Collection findAll()"
      * @ejb:finder signature="java.util.Collection findByName(java.lang.String pname)"
      * query="SELECT OBJECT(user) FROM CMPUser user WHERE user.name= ?1"
      * unchecked="true"
      * result-type-mapping="Remote"
      * method-intf="Home"

      * @ejb:pk generate="false" class="java.lang.Integer"
      * @jboss:table-name table-name="utilisateur"
      * @jboss:create-table create="false"
      * @jboss:remove-table remove="false"
      * @jboss:query name="findByName" query="name = {0}"
      */
      public abstract class EJBCMPUser implements EntityBean, User
      {
      .....
      /**
      * @ejb:persistent-field
      * @ejb:interface-method view-type="remote"
      * @jboss:column-name name="date_naissance"

      * @see org.samples.User#getBirthday()
      */
      public abstract Date getBirthday();
      /**
      * @ejb:persistent-field
      * @ejb:interface-method view-type="remote"
      * @jboss:column-name name="nom"
      * @see org.samples.User#getName()
      */
      public abstract String getName();
      /**
      * @ejb:persistent-field
      * @ejb:interface-method view-type="remote"
      * @jboss:column-name name="prenom"
      * @see org.samples.User#getUsername()
      */
      public abstract String getUsername();

      /**
      * @ejb:create-method view-type="local"
      * @ejb:create-method view-type="remote
      * */
      public Integer ejbCreate(String newName, String newUsername, Date newBirthday) throws CreateException
      {
      setName(newName);
      setUsername(newUsername);
      setBirthday(newBirthday);
      return null;
      }
      public void ejbPostCreate(String newName, String newUsername, Date newBirthday) throws CreateException
      {
      }
      /**
      * @ejb:pk-field
      * @ejb:persistent-field
      * @jboss:column-name name="id"
      * */
      public abstract Integer getId();
      }