when should I use the cmr?

Discussions

EJB programming & troubleshooting: when should I use the cmr?

  1. when should I use the cmr? (2 messages)

    I could not make it clear when should use the cmr , has a standard??
    if the Customer and Address are the many to many relationship ,should use??
    if the Customer and the Account are the one to many should use??

    Threaded Messages (2)

  2. when should I use the cmr?[ Go to top ]

    You can find the answer inside MasteringEJB2 by Ed Roman, chapter "BMP and CMP Relationships". Basically you use the cmr field in order to tell the container which get/set methods correspond to the relationship so that the container can generate the necessary code when subclassing your bean. I will resume to your example:
    if you have a one Customer with many Accounts, you will have inside the <ejb-relationship-role>Customer</ejb-relationship-role> a cmr element like
    <cmr-field><cmr-field-name>Account</cmr-field-name></cmr-field>.

    if you have many Customers with many Addresses, you will have inside the <ejb-relationship-role>Customer</ejb-relationship-role> a cmr element like
    <cmr-field>
      <cmr-field-name>Account</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>.

    For Address its the same as for Customer.
  3. I see[ Go to top ]

    thanks