Hi Neal:
    I think you should add a <key-fields> part in jbosscmp-jdbc.xml at the 
entity role you want jboss to generate a foreign key for you, otherwise 
jboss will generate both as default(my opinion).
    As far as One:N relationship, because it's impossible to set foreigh key 
at the one side(of course you know:>) jboss is smart enough to only generate 
foreign key at many side.

PS: If you want to generate fk only at Repository Entity, you can do like 
this:
<----------jbosscmp-jdbc.xml----------------->
   <relationships>
     <ejb-relation>
       <ejb-relation-name>entry-signature</ejb-relation-name>
       <foreign-key-mapping/>
       <ejb-relationship-role>
       
<ejb-relationship-role-name>has-signature</ejb-relationship-role-name>
*******<key-fields>
*********<key-field>
***********<field-name>id</field-name>
***********<column-name>fk</column-name>
*********</key-field>
*********</key-fields>
       
<ejb-relationship-role-name>one-signature-belong-one-repository</ejb-relationship-role-name>
       <fk-constraint>true</fk-constraint>
       </ejb-relationship-role>
*******<key-fields/>

So, that is. Hope it's helpful to you.

Gene


>Neal wrote:

>Hi All,
>
>Am I misunderstanding the meaning of Unidirectional? I have declared a
>One to One Unidirectional relation from a RepositoryEntry to a
>Signature. When JBoss creates the tables, RepositoryEntry is given a
>signature field, as expected, but it also creates a RepositoryEntry
>field in the Signature table. I don't care about being able to get
>from a Signature back to its RepositoryEntry, in fact I want to be
>able to add Signatures to other objects in my schema besides
>RepositoryEntry.
>
>What's going on? Here's the relations section from the ejb-jar.xml:
>
>    <relationships >
>       <ejb-relation >
>          <ejb-relation-name>entry-signature</ejb-relation-name>
>          <!-- unidirectional -->
>          <ejb-relationship-role >
>
><ejb-relationship-role-name>has-signature</ejb-relationship-role-name>
>             <multiplicity>One</multiplicity>
>             <relationship-role-source >
>                <ejb-name>RepositoryEntry</ejb-name>
>             </relationship-role-source>
>             <cmr-field >
>                <cmr-field-name>signature</cmr-field-name>
>             </cmr-field>
>          </ejb-relationship-role>
>          <ejb-relationship-role >
>
><ejb-relationship-role-name>signature-has-entry</ejb-relationship-role-name>
>             <multiplicity>One</multiplicity>
>             <cascade-delete/>
>             <relationship-role-source >
>                <ejb-name>Signature</ejb-name>
>             </relationship-role-source>
>          </ejb-relationship-role>
>       </ejb-relation>
>    </relationships>
>
>And in my jbosscmp-jdbc.xml I've done the following:
>
>   <relationships>
>     <ejb-relation>
>       <ejb-relation-name>entry-signature</ejb-relation-name>
>       <foreign-key-mapping/>
>       <ejb-relationship-role>
>
><ejb-relationship-role-name>has-signature</ejb-relationship-role-name>
><fk-constraint>true</fk-constraint>
>       </ejb-relationship-role>
>       <ejb-relationship-role>
>
><ejb-relationship-role-name>signature-has-entry</ejb-relationship-role-name>
>           <fk-constraint>false</fk-constraint>
>       </ejb-relationship-role>
>     </ejb-relation>
>   </relationships>
>
>The <fk-constraint> elements I added recently to see if they had an
>effect on the Signature table, but they don't.
>
>Next I tried making the multiplicity Many on the RepositoryEntry side
>of the relation, and regeneration of the tables shows that the field
>in the Signature table is not there anymore. Why is it present in a 1
>to 1 unidirectional relation, and not in a Many to One?
>
>Thanks for enlightenment. :)
>
>-Neal
>
>
>--__--__--



_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to