2 Replies Latest reply on Jul 21, 2005 7:17 AM by Joern

    n:m <relation-table> is not used

    Joern Newbie

      Hi,

      i get an exception when calling my finder. i use a relationtable(report_role_map) that is not created by jboss. my finder always uses a table t2_r_roles_RELATION_TABLE, that (of course) dont exists. can somebody help please?

      error:

      14:39:13,808 DEBUG [Report#findReportByRole] Executing SQL: SELECT t0_r.id FROM report t0_r WHERE ((t2_r_roles_RELATION_TABLE.fk_role_id IS NOT NULL AND t2_r_roles_RELATION_TABLE.fk_report_id=?))
      14:39:13,808 ERROR [Report#findReportByRole] Find failed
      java.sql.SQLException: Unknown table 't2_r_roles_RELATION_TABLE' in where clause
       at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)
       at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531)
       at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622)
      


      my jbosscmp-jdbc:

      <relationships>
       <ejb-relation>
       <ejb-relation-name>Report-Role</ejb-relation-name>
       <relation-table-mapping>
       <table-name>report_role_map</table-name>
       <create-table>false</create-table>
       <remove-table>false</remove-table>
       </relation-table-mapping>
      
       <ejb-relationship-role>
       <ejb-relationship-role-name>Report-has-Roles</ejb-relationship-role-name>
       <fk-constraint>true</fk-constraint>
       <key-fields>
       <key-field>
       <field-name>id</field-name>
       <column-name>fk_role_id</column-name>
       </key-field>
       </key-fields>
      
       </ejb-relationship-role>
       <ejb-relationship-role>
       <ejb-relationship-role-name>Role-has-Reports</ejb-relationship-role-name>
       <fk-constraint>true</fk-constraint>
       <key-fields>
       <key-field>
       <field-name>id</field-name>
       <column-name>fk_report_id</column-name>
       </key-field>
       </key-fields>
      
       </ejb-relationship-role>
       </ejb-relation>
      


      my tables:


      CREATE TABLE `role` (
       `id` int(11) NOT NULL default '0',
       `rolename` varchar(32) NOT NULL default '',
       PRIMARY KEY (`id`)
      )
      
      
      CREATE TABLE `report` (
       `id` int(10) unsigned NOT NULL auto_increment,
       `comment` varchar(100) NOT NULL default '',
       PRIMARY KEY (`id`)
      )
      
      relation-table:
      
      CREATE TABLE `report_role_map` (
       `fk_report_id` int(11) NOT NULL default '0',
       `fk_role_id` int(11) NOT NULL default '0'
      )
      


      my finder:

       * @ejb.finder signature = "java.util.Collection findReportByRole(de.entity.interfaces.RoleLocal role)"
       * query = "SELECT OBJECT(r) FROM Report AS r WHERE ?1 MEMBER OF r.roles"
      


      if you need more information please tell me...

      thx a lot

        • 1. Re: n:m <relation-table> is not used
          Joern Newbie

          this topic is similar but dont solve my problem:
          http://www.jbossgroup.com/index.html?module=bb&op=viewtopic&t=50729

          some more code:

          roles in my ejb-jar.xml

          <relationships >
           <ejb-relation >
           <ejb-relation-name>Report-Role</ejb-relation-name>
          
           <ejb-relationship-role >
           <ejb-relationship-role-name>Report-has-Roles</ejb-relationship-role-name>
           <multiplicity>Many</multiplicity>
           <relationship-role-source >
           <ejb-name>Report</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-relationship-role >
           <ejb-relationship-role-name>Role-has-Reports</ejb-relationship-role-name>
           <multiplicity>Many</multiplicity>
           <relationship-role-source >
           <ejb-name>Role</ejb-name>
           </relationship-role-source>
           <cmr-field >
           <cmr-field-name>report</cmr-field-name>
           <cmr-field-type>java.util.Collection</cmr-field-type>
           </cmr-field>
           </ejb-relationship-role>
          
           </ejb-relation>
           <!--
           To add relationships for beans not managed by XDoclet, add
           a file to your XDoclet merge directory called relationships.xml that contains
           the <ejb-relation></ejb-relation> markups for those beans.
           -->
           </relationships>
          


          jboss.xml

           <entity>
           <ejb-name>Report</ejb-name>
           <jndi-name>ejb/ReportHome</jndi-name>
           <local-jndi-name>ejb/ReportLocalHome</local-jndi-name>
          
           <method-attributes>
           </method-attributes>
          
           </entity>
           <entity>
           <ejb-name>Role</ejb-name>
           <jndi-name>ejb/RoleHome</jndi-name>
           <local-jndi-name>ejb/RoleLocalHome</local-jndi-name>
          
           <method-attributes>
           </method-attributes>
          
           </entity>
          


          please give me a hint...

          • 2. Re: n:m <relation-table> is not used
            Joern Newbie

            one more try:

            if i change the ralation-table to:

            <relation-table-mapping>
            <table-name>report_role_map</table-name>
            <create-table>true</create-table>
            <remove-table>true</remove-table>
            </relation-table-mapping>

            the table is removed while undeploying, but not created while deploying??!! i'm confused...

            please help :(