1 Reply Latest reply on Aug 26, 2004 6:30 PM by janprill

    Error while creating table in CMP

    Sathya Sekar Newbie

      Hi,

      I am using (My)Eclipse, XDoclet and MySQL for developing my EJBs.

      I have an entity bean whose corresponding table requires to be created in the database. All my compiles and deployment goes through fine - but MySQL throws an error complaining the max column size for a VARCHAR field is 256.

      My jbosscmp-jdbc.xml shows correct details :

       <entity>
       <ejb-name>Composer</ejb-name>
       <table-name>Composer</table-name>
      
       <cmp-field>
       <field-name>composerName</field-name>
       <column-name>composerName</column-name>
      
       <jdbc-type>VARCHAR</jdbc-type>
       <sql-type>varchar(50)</sql-type>
      
       </cmp-field>
       <cmp-field>
       <field-name>genre</field-name>
       <column-name>genre</column-name>
      
       <jdbc-type>VARCHAR</jdbc-type>
       <sql-type>varchar(60)</sql-type>
      
       </cmp-field>
      
      <!-- jboss 3.2 features -->
      <!-- optimistic locking does not express the exclusions needed -->
       </entity>
      



      The errror thrown is :

      :36:19,596 WARN [ServiceController] Problem starting service jboss.j2ee:jndiName=Composer,service=EJB
      MBeanException: org.jboss.deployment.DeploymentException: Error while creating table Composer; - nested throwable: (java.sql.SQLException: Syntax error or access violation message from server: "Too big column length for column 'composerName' (max = 255). Use BLOB instead")
      
      Cause: org.jboss.deployment.DeploymentException: Error while creating table Composer; - nested throwable: (java.sql.SQLException: Syntax error or access violation message from server: "Too big column length for column 'composerName' (max = 255). Use BLOB instead")
      


      From the JBoss log :

      2004-08-26 15:36:19,507 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.Composer] Executing SQL: CREATE TABLE Composer (composerName VARCHAR(256), definitiveFilm VARCHAR(256), CONSTRAINT pk_Composer PRIMARY KEY ())
      


      Why is it trying to create a table with column size varchar(256) when it has been specified to be much lower ?

      I attempted a number of XDoclet tag changes and manipulations but none worked. Any inputs on this ?

      Thanks

        • 1. Re: Error while creating table in CMP
          janprill Novice

          Are you sure that you have deployed your mysql-ds.xml correctly? Here is a snippet that definitly creates VARCHAR with a length of 100 correctly.

          <cmp-field>
           <field-name>createdId</field-name>
           <column-name>FK_CREATED_ID</column-name>
          
           <jdbc-type>VARCHAR</jdbc-type>
           <sql-type>VARCHAR(100)</sql-type>
          
           </cmp-field>
           <cmp-field>
           <field-name>changedId</field-name>
           <column-name>FK_CHANGED_ID</column-name>
          
           <jdbc-type>VARCHAR</jdbc-type>
           <sql-type>VARCHAR(100)</sql-type>
          
           </cmp-field>