2 Replies Latest reply on Jul 8, 2002 12:07 PM by prashantpatel

    Unidirectional One - One Mapping table creation

    prashantpatel

      After creation a unidirectional one-one mapping like this.
      public abstract class AccountEntityBean implements EntityBean
      {
      public abstract LocalCommunicationInfo getCommInfo();
      public abstract void setCommInfo(LocalCommunicationInfo info);
      }

      public abstract class CommunicationInfoEntityBean implements EntityBean{}


      <ejb-relation>
      <ejb-relation-name>Account-CommunicationInfo</ejb-relation-name>
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Account-has-CommunicationInfo
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>AccountEntity</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>CommInfo</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Account-has-Communication
      </ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>CommunicationInfoEntity</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>


      The table account and communicationInfo are created but it does not create uni-directional relationship as
      account has commoid as foreign key and the communicationinfo table also has a foreign key of account, the field in the communicationinfo is generated by the container Accountentity_comminfo which is have not specified by me in any *.xml file.
      I dont want communicationinfo to have any account foreign key. Also seeing some earlier posts on such relation why do we need to have the same tag in jbosscmp-jdbc.xml is there any config in the
      jbosscmp-jdbc.xml to get the undirectional relational i desire.

        • 1. Re: Unidirectional One - One Mapping table creation
          prashantpatel

          Now i am getting the relationship i desire like this is it the right way.


          <ejb-relation>
          <ejb-relation-name>Account-CommunicationInfo</ejb-relation-name>
          <foreign-key-mapping />
          <ejb-relationship-role>
          <ejb-relationship-role-name>
          Account-has-CommunicationInfo
          </ejb-relationship-role-name>
          <fk-constraint>true</fk-constraint>
          <!-- <key-fields>
          <key-field>
          <field-name>AccOid</field-name>
          <column-name>AccOid</column-name>
          </key-field>
          </key-fields> -->
          </ejb-relationship-role>
          <ejb-relationship-role>
          <ejb-relationship-role-name>
          Account-has-Communication
          </ejb-relationship-role-name>
          <fk-constraint>false</fk-constraint>
          </ejb-relationship-role>
          </ejb-relation>

          What is the diffrence b/w
          "foreign-key-mapping and relation-table-mapping"
          Prashant patel

          • 2. Re: Unidirectional One - One Mapping table creation
            prashantpatel

            As you see i have commented the key-field tag which created field in communicationinfo after that jboss created a field in communicationinfo that i did not specify does jboss use this key for other purpose, but i am getting the relationship result i desired.

            Prashant Patel