1 Reply Latest reply on Jun 20, 2002 10:02 PM by Sebastien ASTIE

    CMR M:N relation

    Sebastien ASTIE Newbie

      hello,

      I have a problem with jboss 3.0 final and CMR.
      I have set my M:N relation with table mapping.
      I have an exception when i try to get the information from the DB corresponding to one of the 2 EJBs using the get method on my cmr field.

      The exception says that jboss doesn't find a table corresponding to my relation:

      java.sql.SQLException: General error: Table 'virconprojtrck.tproject_usersinvolvedinproject_tuser_projectsinvolvedin' doesn't exist
      at org.gjt.mm.mysql.MysqlIO.sendCommand(Unknown Source)
      at org.gjt.mm.mysql.MysqlIO.sqlQueryDirect(Unknown Source)
      at org.gjt.mm.mysql.Connection.execSQL(Unknown Source)
      at org.gjt.mm.mysql.PreparedStatement.executeQuery(Unknown Source)
      at org.jboss.resource.adapter.jdbc.local.LocalPreparedStatement.executeQuery(LocalPreparedStatement.java:289)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadRelationCommand.execute(JDBCLoadRelationCommand.java:96)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadRelation(JDBCStoreManager.java:567)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.load(JDBCCMRFieldBridge.java:889)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getInstanceValue(JDBCCMRFieldBridge.java:571)
      at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMRFieldBridge.getValue(JDBCCMRFieldBridge.java:545)


      The table tproject_usersinvolvedinproject_tuser_projectsinvolvedin doesn't exist in my system, it is just the concatenation of my 2 CMR field names....

      here is a piece of my ejb-jar.xml


      <display-name>TProject</display-name>
      <ejb-name>TProject</ejb-name>
      <local-home>com.powah.vircon.projecttracking.backlogic.ejb.entity.cmp.project.TProjectHome</local-home>
      com.powah.vircon.projecttracking.backlogic.ejb.entity.cmp.project.TProject
      <ejb-class>com.powah.vircon.projecttracking.backlogic.ejb.entity.cmp.project.TProjectBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>TProject</abstract-schema-name>
      <cmp-field>
      <field-name>projectId</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>name</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>completionStatus</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>description</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>creationDate</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>startDate</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>dueDate</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>comments</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>estimatedTimeCost</field-name>
      </cmp-field>
      <primkey-field>projectId</primkey-field>

      <query-method>
      <method-name>findAll</method-name>
      <method-params />
      </query-method>
      <result-type-mapping>Local</result-type-mapping>
      <ejb-ql>SELECT DISTINCT OBJECT(proj) FROM TProject proj</ejb-ql>





      <display-name>TUser</display-name>
      <ejb-name>TUser</ejb-name>
      <local-home>com.powah.vircon.projecttracking.backlogic.ejb.entity.cmp.user.TUserHome</local-home>
      com.powah.vircon.projecttracking.backlogic.ejb.entity.cmp.user.TUser
      <ejb-class>com.powah.vircon.projecttracking.backlogic.ejb.entity.cmp.user.TUserBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.Integer</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>TUser</abstract-schema-name>
      <cmp-field>
      <field-name>userid</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>rights</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>firstName</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>lastName</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>email</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>password</field-name>
      </cmp-field>
      <cmp-field>
      <field-name>department</field-name>
      </cmp-field>
      <primkey-field>userid</primkey-field>

      <query-method>
      <method-name>findByEmail</method-name>
      <method-params>
      <method-param>java.lang.String</method-param>
      </method-params>
      </query-method>
      <result-type-mapping>Local</result-type-mapping>
      <ejb-ql>SELECT DISTINCT OBJECT(user) FROM TUser user WHERE user.email = ?1</ejb-ql>




      <ejb-relation>
      <ejb-relation-name>Project-ParticipantUser</ejb-relation-name>
      <ejb-relationship-role>
      tProject
      <ejb-relationship-role-name>TProjectRelationshipRole</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      tProject
      <ejb-name>TProject</ejb-name>
      </relationship-role-source>
      <cmr-field>
      tUser
      <cmr-field-name>usersInvolvedInProject</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role>
      tUser
      <ejb-relationship-role-name>TUserRelationshipRole</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      tUser
      <ejb-name>TUser</ejb-name>
      </relationship-role-source>
      <cmr-field>
      tProject
      <cmr-field-name>projectsInvolvedIn</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      </ejb-relation>


      jbossjdbc-cmp.xml :

      <ejb-relation>
      <ejb-relation-name>Project-ParticipantUser</ejb-relation-name>
      <table-mapping>
      <table-name>tuserproject</table-name>
      <create-table>false</create-table>
      <remove-table>false</remove-table>
      <ejb-relationship-role>
      <ejb-relationship-role-name>TProjectRelationshipRole</ejb-relationship-role-name>
      <table-key-fields>
      <table-key-field>
      <field-name>projectId</field-name>
      <column-name>projectId</column-name>
      </table-key-field>
      </table-key-fields>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>TUserRelationshipRole</ejb-relationship-role-name>
      <table-key-fields>
      <table-key-field>
      <field-name>userid</field-name>
      <column-name>userID</column-name>
      </table-key-field>
      </table-key-fields>
      </ejb-relationship-role>
      </table-mapping>
      </ejb-relation>



      If any body knows what's going on let me know please, your help will be greatly appreciated.

      Thanks