Discussions

EJB programming & troubleshooting: referential integrity through CMR

  1. referential integrity through CMR (1 messages)

    How do I define a referential integrity between a unique key(non-primary key) and foreign key in CMR.I am using weblogic 8.1
  2. referential integrity through CMR[ Go to top ]

    First decide the type of relation ie one-one or one-many etc. After that in ejb-jar.xml file, we need to add <relationships> section. This will look something like the below

       <relationships>
       <!-- Start of HP end relations -->
            <ejb-relation>
                <description/>
                <ejb-relation-name>HPEntityCanHaveMultipleHPMerchInfoEntitys</ejb-relation-name>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>OneHpEntityHasManyHPMerchInfoEntity</ejb-relationship-role-name>
                    <multiplicity>One</multiplicity>
                    <relationship-role-source>
                        <ejb-name>HPEntity</ejb-name>
                    </relationship-role-source>
                    <cmr-field>
                        <cmr-field-name>hpMerchInfos</cmr-field-name>
                        <cmr-field-type>java.util.Collection</cmr-field-type>
                    </cmr-field>
                </ejb-relationship-role>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>ManyHPMerchInfoEntityBelongstoOneHPEntity</ejb-relationship-role-name>
                    <multiplicity>Many</multiplicity>
                    <relationship-role-source>
                        <ejb-name>HPMerchInfoEntity</ejb-name>
                    </relationship-role-source>
                </ejb-relationship-role>
            </ejb-relation>
    </relationships>

    Basically we need to define the relationships between our Entity Beans.