Hello Dulshan,
I'm moving you to jboss-user list.
DDS> Is there some thing wrong in the way I'm doing it in the Jboss.
I would say you do it wrong in WL either. There is no need to declare
two relationships. Just remove one of them.
In case of unidirectional relationships you don't declare abstract
accessors on the blind side.
alex
Tuesday, December 10, 2002, 10:39:18 PM, you wrote:
DDS> Hello,
DDS> I'm trying to implement CMP 2.0 one to many bi directional relation in Jboss
tomcat 3.0.4.I have to classes. One called Individual and the other is called
DDS> AccountEmail. The application works without a trouble in Weblogic 7.0 without any
problem.
DDS> The bidirectional relationship is as follows,
DDS> (1) Individual ---> many AccountEmail (1 -> 0..m) (cmr field is accountemails)
DDS> (2) AccountEmail ----> one Individual (1-> 1) (cmr is individual)
DDS> In the IndividualBean class I have these methods to form the relationships
DDS> //abstract accessor and Mutator
DDS> public abstract java.util.Collection getAccountemails();
DDS> public abstract void setAccountemails(java.util.Collection accountemails);
DDS> //and an add Method to add a single instance of AccountEmail to Individual
DDS> public void addAccountEmail(LocalAccountEmail accountemail){
DDS> getAccountemails().add(accountemail);
DDS> }
DDS> In the AccountEmailBean class I have the following methods to form the
relationship
DDS> //abstract accessor and Mutator
DDS> public abstract void setIndividual(LocalIndividual individual);
DDS> public abstract LocalIndividual getIndividual();
DDS> I have defined the relationsuip in the descriptors as follows,
DDS> In ejb-jar.xml
DDS> ================
DDS> <ejb-relation>
DDS> <ejb-relation-name>individual-accountEmail</ejb-relation-name>
DDS> <ejb-relationship-role>
DDS> <description>individual</description>
DDS>
<ejb-relationship-role-name>IndividualRelationshipRole</ejb-relationship-role-name>
DDS> <multiplicity>One</multiplicity>
DDS> <relationship-role-source>
DDS> <description>individual</description>
DDS> <ejb-name>Individual</ejb-name>
DDS> </relationship-role-source>
DDS> <cmr-field>
DDS> <description>accountEmail</description>
DDS> <cmr-field-name>accountemails</cmr-field-name>
DDS> <cmr-field-type>java.util.Collection</cmr-field-type>
DDS> </cmr-field>
DDS> </ejb-relationship-role>
DDS> <ejb-relationship-role>
DDS> <description>accountEmail</description>
DDS>
<ejb-relationship-role-name>AccountEmailRelationshipRole</ejb-relationship-role-name>
DDS> <multiplicity>Many</multiplicity>
DDS> <relationship-role-source>
DDS> <description>accountEmail</description>
DDS> <ejb-name>AccountEmail</ejb-name>
DDS> </relationship-role-source>
DDS> </ejb-relationship-role>
DDS> </ejb-relation>
DDS> <ejb-relation>
DDS> <ejb-relation-name>accountEmail-individual</ejb-relation-name>
DDS> <ejb-relationship-role>
DDS> <description>accountEmail</description>
DDS>
<ejb-relationship-role-name>AccountEmailRelationshipRole</ejb-relationship-role-name>
DDS> <multiplicity>One</multiplicity>
DDS> <relationship-role-source>
DDS> <description>accountEmail</description>
DDS> <ejb-name>AccountEmail</ejb-name>
DDS> </relationship-role-source>
DDS> <cmr-field>
DDS> <description>individual</description>
DDS> <cmr-field-name>individual</cmr-field-name>
DDS> </cmr-field>
DDS> </ejb-relationship-role>
DDS> <ejb-relationship-role>
DDS> <description>individual</description>
DDS>
<ejb-relationship-role-name>IndividualRelationshipRole</ejb-relationship-role-name>
DDS> <multiplicity>One</multiplicity>
DDS> <relationship-role-source>
DDS> <description>individual</description>
DDS> <ejb-name>Individual</ejb-name>
DDS> </relationship-role-source>
DDS> </ejb-relationship-role>
DDS> </ejb-relation>
DDS> In jbosscmp-jdbc.xml
DDS> =====================
DDS> <ejb-relation>
DDS> <ejb-relation-name>individual-accountEmail</ejb-relation-name>
DDS> <foreign-key-mapping/>
DDS> <ejb-relationship-role>
DDS>
<ejb-relationship-role-name>IndividualRelationshipRole</ejb-relationship-role-name>
DDS> <key-fields>
DDS> <key-field>
DDS> <field-name>personid</field-name>
DDS> <column-name>personid</column-name>
DDS> </key-field>
DDS> </key-fields>
DDS> </ejb-relationship-role>
DDS> <ejb-relationship-role>
DDS>
<ejb-relationship-role-name>AccountEmailRelationshipRole</ejb-relationship-role-name>
DDS> <key-fields/>
DDS> </ejb-relationship-role>
DDS> </ejb-relation>
DDS> <ejb-relation>
DDS> <ejb-relation-name>accountEmail-individual</ejb-relation-name>
DDS> <foreign-key-mapping/>
DDS> <ejb-relationship-role>
DDS>
<ejb-relationship-role-name>AccountEmailRelationshipRole</ejb-relationship-role-name>
DDS> <key-fields/>
DDS> </ejb-relationship-role>
DDS> <ejb-relationship-role>
DDS>
<ejb-relationship-role-name>IndividualRelationshipRole</ejb-relationship-role-name>
DDS> <key-fields>
DDS> <key-field>
DDS> <field-name>personid</field-name>
DDS> <column-name>personid</column-name>
DDS> </key-field>
DDS> </key-fields>
DDS> </ejb-relationship-role>
DDS> </ejb-relation>
DDS> when I tried to deploy this this gave me a Duplicate key Exception. I totally
removed the relationship declereration in the
DDS> jbosscmp-jdbc.xml file and the container deployed the aplication using the
standard form of column mapping by taking the relations in ejb-jar.xml.This created
DDS> to additional columns, not one column like it is done by weblogic. Then I changed
the jbosscmp-jdbc.xml desciptor entries to avoid the duplicate key
DDS> exception like this.
DDS> <ejb-relation>
DDS> <ejb-relation-name>individual-accountEmail</ejb-relation-name>
DDS> <foreign-key-mapping/>
DDS> <ejb-relationship-role>
DDS>
<ejb-relationship-role-name>IndividualRelationshipRole</ejb-relationship-role-name>
DDS> <key-fields>
DDS> <key-field>
DDS> <field-name>personid</field-name>
DDS> <column-name>personid</column-name>
DDS> </key-field>
DDS> </key-fields>
DDS> </ejb-relationship-role>
DDS> <ejb-relationship-role>
DDS>
<ejb-relationship-role-name>AccountEmailRelationshipRole</ejb-relationship-role-name>
DDS> <key-fields/>
DDS> </ejb-relationship-role>
DDS> </ejb-relation>
DDS> <ejb-relation>
DDS> <ejb-relation-name>accountEmail-individual</ejb-relation-name>
DDS> <foreign-key-mapping/>
DDS> <ejb-relationship-role>
DDS>
<ejb-relationship-role-name>AccountEmailRelationshipRole</ejb-relationship-role-name>
DDS> <key-fields/>
DDS> </ejb-relationship-role>
DDS> <ejb-relationship-role>
DDS>
<ejb-relationship-role-name>IndividualRelationshipRole</ejb-relationship-role-name>
DDS> <key-fields>
DDS> <key-field>
DDS> <field-name>personid</field-name>
DDS> <column-name>personid2</column-name>
DDS> </key-field>
DDS> </key-fields>
DDS> </ejb-relationship-role>
DDS> </ejb-relation>
DDS> This timeit was able to deploy my application and it created two columns named
personid and personid2 in the database table for
DDS> AccountEmail Bean.It looked like the things work well. But it failed without
giving any error. The reason was
DDS> the application doesn't set the reverse reference from AccountEmail to the
Individual in the personid2 column in the database.
DDS> When we query for the account email bean and try to retireve its corresponding
individual it returns null.
DDS> The reason could be that when I added the account email using
DDS> public void addAccountEmail(LocalAccountEmail accountemail){
DDS> getAccountemails().add(accountemail);
DDS> }
DDS> Definitely the container only completed one path of the Bi directional
relationship.
DDS> Is there some thing wrong in the way I'm doing it in the Jboss. Can some one
please help me out in this.
DDS> Regards!!!
DDS> Dulshan De Silva
-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user