-
1. Re: CMP2 jbosscmp foreignkey mapping problem
ups2000 Mar 27, 2002 4:08 PM (in response to haowu)I have exactly the same problem
Anyone can help please? -
2. Re: CMP2 jbosscmp foreignkey mapping problem
pazu Mar 28, 2002 7:47 AM (in response to haowu)The DTD for jbosscmp-jdbc.xml has changed between beta1 and beta2. Please take a look at the new DTD.
<foreign-key-mapping> is now an EMPTY element and you use <key-fields> to indicate which fields are used as foreign key. Read the DTD carefully. -
3. Re: CMP2 jbosscmp foreignkey mapping problem
mcauleyt Mar 28, 2002 9:15 AM (in response to haowu)Have a look at this for an example, it might help. Validating against the dtd file is always useful!
Tim
*************
<ejb-relation>
<ejb-relation-name>Member-MemberInterest</ejb-relation-name>
<foreign-key-mapping/>
<ejb-relationship-role>
<ejb-relationship-role-name>Member-has-MemberInterests</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>memberPk</field-name>
<column-name>member_memberpk</column-name>
</key-field>
</key-fields>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>MemberInterest-is-composed-of-a-member-reference</ejb-relationship-role-name>
<key-fields/>
</ejb-relationship-role>
</ejb-relation>
**************
ejb-jar.xml
**************
<ejb-relation>
<ejb-relation-name>Member-MemberInterest</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>Member-has-MemberInterests</ejb-relationship-role-name>
One
<relationship-role-source>
<ejb-name>MemberEJB</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>interests</cmr-field-name>
<cmr-field-type>java.util.Set</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>MemberInterest-is-composed-of-a-member-reference</ejb-relationship-role-name>
Many
<relationship-role-source>
<ejb-name>MemberInterestEJB</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>member</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
</ejb-relation> -
4. Re: CMP2 jbosscmp foreignkey mapping problem
knorki Mar 28, 2002 9:41 AM (in response to haowu)Could you tell me where i can find the DTDs ? I serched jboss.org and on Sourceforge but i did't find anything... :-(
thanks
Knorki -
5. Re: CMP2 jbosscmp foreignkey mapping problem
haowu Mar 28, 2002 1:31 PM (in response to haowu)Excellent demyth! As soon as I moved out ejb-relationship-role of foreign-key-mapping and added key-fields into it, it worked like a charm.
Knorki, the DTD is right under your nose. :) If you have beta2, you must have built by yourself. Check under jboss-all/server/src/resources/org/jboss/metadata. It's also available at http://www.jboss.org/j2ee/dtd, but it has the old version (beta instead of beta2).
--Hao -
6. Re: CMP2 jbosscmp foreignkey mapping problem
haowu Mar 28, 2002 1:38 PM (in response to haowu)Sorry, I didn't use the tag right. Here's what I did -
1. Moved ejb-relationship-role out of foreign-key-mapping
2. Add key-fields into ejb-relationship-role.
3. You can throw away foreign-key-mapping
Note in key-field, the field-name refers to the primary key field(s) of the target Bean, whereas the column-name refers to the source Table.
--Hao -
7. Re: CMP2 jbosscmp foreignkey mapping problem
knorki Apr 3, 2002 1:45 AM (in response to haowu)Hi ... thanks for the link to the dtd. But I think this dtd is not even for the beta its for the alpha. because beta also uses
key-fields instead of foreign-key-fields, but it works fine now
cu
knorki