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

    JBoss CMP MySQL and Auto-Increment Keys - with Relationships

    mpforste

      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'"

        • 1. Re: JBoss CMP MySQL and Auto-Increment Keys - with Relations
          sesques

          Hi,

          Your problem seems comes from the relationship definition, not the auto-increment key.
          How do you define the relationship (name, role, fields) ?

          • 2. Re: JBoss CMP MySQL and Auto-Increment Keys - with Relations
            mpforste

            we Solved the first problem - it was a misunderstanding of how to do it - we have solved the problem there but now we are getting the following error
            java.lang.IllegalStateException: Failed to find method for hash:-5458560701547371797
            Failed to find method for hash:-5458560701547371797
            Failed to find method for hash:-5458560701547371797

            We are looking into it and have purchased a book on JBoss 3.2 Deployment and administration which should help but any further help would be appreciated.