1 Reply Latest reply on Mar 29, 2004 4:48 AM by aloubyansky

    EJB CMR questions

    bmenarek

      My name is John and I am having some difficulty getting CMR to work.

      I was hoping you could answer some questions.

      I have two EJBs the first BillingEJB has a ContactEJB, it is a unidirectional one to one relationship.

      My first question is the <ejb-relationship-role> in the jbosscmp-jdbc.xml file
      <ejb-relationship-role>
      <ejb-relationship-role-name>
      Billing-Has-Contact
      </ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <!-- Note: Field in Billing. -->
      <field-name>billingId</field-name>
      <!-- Note: Column in Contact table. -->
      <column-name>phoneNumber</column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>

      As I understand it the reference EJB is Billing so why do I have specify its key? shouldn't it be something like
      <key-fields>
      <key-field>
      <!-- Note: Field in Billing. -->
      <field-name>
      contactPhoneNumber
      </field-name> THE FOREIGN KEY
      <!-- Note: Column in Contact table. -->
      <column-name>
      phoneNumber
      </column-name> THE PK in ContactEJB
      </key-field>
      </key-fields>

      My second question is does it make any sense to have a remote interface with an EJB that has a CMR relationship. The reason I state this is because as I currently understand it, only the local interface can only be used to set the cmr field in the postCreate method. Which leads me to see the requirement for session EJB's because they would have to "wire" all this stuff together server side for the client.

      Any help would be greatly appreciated


      John Menarek

        • 1. Re: EJB CMR questions
          aloubyansky

          key-field mapps a primary key field to a foreign key column. I don't know whether the mapping you posted is correct in the context of your application.
          An entity bean with CMR can also have remote interface but CMR can only be accessed within local interfaces.