[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - relationships in jbosscmp-jdbc.xml

paoletto do-not-reply at jboss.com
Fri Jun 8 05:50:32 EDT 2007


so, i have this doubt about sematics of fields in jbosscmp-jdbc.

example taken from a working project:


  |     <ejb-relation>
  |       <ejb-relation-name>Students-Groups</ejb-relation-name>
  | 
  |       <foreign-key-mapping/>
  | 
  |       <ejb-relationship-role>
  |           <ejb-relationship-role-name>Student-belongs-to-group</ejb-relationship-role-name>
  | 		  <key-fields/>
  | 
  |       </ejb-relationship-role>
  |       <ejb-relationship-role>
  |           <ejb-relationship-role-name>Group-has-students</ejb-relationship-role-name>
  |           <key-fields>
  |              <key-field>
  |                <field-name>id</field-name>
  |                <column-name>refGroup</column-name>
  |              </key-field>
  |           </key-fields>
  | 
  |       </ejb-relationship-role>
  |     </ejb-relation>
  | 

ok. i had a look in the code and id is a CMP field of entity  "group" and "refGroup" is a field of entity and table students.

now what i was wondering:
ok, i desume that this key-field block is used to express a foreign key, where field name is the local cmp field mapped above in the file, and column name is the foreign column in the other table, stated this time in ejb-jar.xml relations block.

is this correct? i ask because in the .dtd file it is not explained well, and it seems that usually <column-name> is the actual column name in the db of <field-name>, so it's not so obvious that things are how im figuring out

thanks for any explaination

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4052476#4052476

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4052476



More information about the jboss-user mailing list