2 Replies Latest reply on Apr 8, 2004 9:57 AM by Michael Forster

    JBoss CMP MySQL and Auto-Increment Keys - with Relationships

    Michael Forster Newbie

      I am having problems getting JBoss talking correctly with the MySQL database and an autoincrement Primary Key.
      DB =
      Create Table `TransType`
      ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
      `tt_desc` VARCHAR(50) NOT NULL,
      PRIMARY KEY ( `id` )
      );

      on another table there is a field
      tr_type BIGINT UNSIGNED NOT NULL,

      This is set up as a relationship to the TransType table.
      I read that you need to declare the PK with JBOSS CMP to java.lang.Object and not declare a name in the mapping and the CMP will deal with it.
      I tried this and it still didn't work - this time the error from JBOss was


      Depends On Me: , ObjectName: jboss.j2ee:jndiName=TransTypeBean,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Atleast one role of a
      foreign-key mapped relationship must have key fields (or <primkey-field> is miss
      ing from ejb-jar.xml): ejb-relation-name=null, ObjectName: jboss.j2ee:jndiName=T
      ransactionBean,service=EJB
      state: FAILED
      I Depend On:
      Depends On Me: org.jboss.deployment.DeploymentException: Atleast one role of a foreign-key mapped relationship must have key fields (or <primkey-field> is missing from ejb-jar.xml): ejb-relation-name=null]

      Can you aadvise how to cope with the Auto increment fields in MySQL and JBOSS so that we can get the system working as required.

      Thanks in advance.

      Footnote - Tomcat returns the following

      javax.ejb.CreateException: Error checking if entity exists:java.sql.SQLException: Column not found message from server: "Unknown column 'TransTypeBean_upk' in 'where clause'"
      Error checking if entity exists:java.sql.SQLException: Column not found message from server: "Unknown column 'TransTypeBean_upk' in 'where clause'"
      Error checking if entity exists:java.sql.SQLException: Column not found message from server: "Unknown column 'TransTypeBean_upk' in 'where clause'"