1 Reply Latest reply on Feb 12, 2002 12:52 PM by F Zemen

    SQL Exception when deploying relation-table-mapping

    F Zemen Newbie

      JBoss 3.0 codebase from Sunday February 10th.
      MySQL 3.23.47

      I'm deploying a many to many relationship between two EJBs. The EJBs all have primary keys as Strings. Many to one relationships deploy fine and everything deploys without the many-to-many relationship.

      The error occurs on intersection table creation and is:

      org.jboss.deployment.DeploymentException: Error while creating table, Cause: java.sql.SQLException: General error: All p
      arts of a PRIMARY KEY must be NOT NULL; If you need NULL in a key, use UNIQUE instead
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.createTable(Unknown Source)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.execute(Unknown Source)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(Unknown Source)
      at org.jboss.ejb.plugins.CMPPersistenceManager.start(Unknown Source)
      at org.jboss.ejb.EntityContainer.start(Unknown Source)
      at org.jboss.ejb.Application.start(Unknown Source)
      at org.jboss.ejb.EJBDeployer.deploy(Unknown Source)
      at org.jboss.deployment.MainDeployer.deploy(Unknown Source)
      at org.jboss.deployment.MainDeployer.deploy(Unknown Source)
      at org.jboss.deployment.MainDeployer.scan(Unknown Source)
      at org.jboss.deployment.MainDeployer.startService(Unknown Source)
      at org.jboss.system.ServiceMBeanSupport.start(Unknown Source)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
      at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
      at org.jboss.system.Server.(Unknown Source)
      at org.jboss.Main.boot(Unknown Source)
      at org.jboss.Main.run(Unknown Source)

      The relevant relationship is:

      <ejb-relation>
      <ejb-relation-name>Role-RolePermission</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Role-has-RolePermissions</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>Role</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>rolePermissions</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>RolePermission-used-in-Roles</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>RolePermission</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>roles</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>


      <ejb-relation>
      <ejb-relation-name>Role-RolePermission</ejb-relation-name>
      <relation-table-mapping>
      <table-name>role_rolepermission</table-name>
      java:/FolioDS
      <create-table>true</create-table>
      <remove-table>false</remove-table>
      </relation-table-mapping>
      <ejb-relationship-role>
      <ejb-relationship-role-name>Role-has-RolePermissions</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>name</field-name>
      <column-name>role</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(32) BINARY</sql-type>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>RolePermission-used-in-Roles</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>name</field-name>
      <column-name>rolepermission</column-name>
      <jdbc-type>VARCHAR</jdbc-type>
      <sql-type>VARCHAR(32) BINARY</sql-type>
      </key-field>
      </key-fields>
      </ejb-relationship-role>
      </ejb-relation>

      Any thoughts?