• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

is there anything wrong here ?

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all.
I need your help please.
I have two CMP beans, PlayerBean and TeamBean.
the relationship is one to many and bidirectional.
TeamBean has a CMR field called plalyers and PlayerBean has a CMR field called team, and there
are a setter and getter methods for these fields in each bean.
the database schema for TeamBean is :
TEAM_NAME, TEAM_CITY
and the bean contains the following fields :
name, city
the database schema for Player bean is :
ID, FULLNAME, NAME // name is the name of the city
and the bean contained the following fields :
id, fullname, name
here is a snipet from jboss-jdbc.xml :

my questions are :
1. is the relationships element right ?
2. what is the value of <field-name> should be ?
id (which is the name of a field in PlayerBean class) or
ID (which is the name of the field in database schema) ?
3. what is the value of <column-name> should be ?
TEAM_NAME (which is the name of a field in Team database schema) or
NAME (which is the name of a field in Player database schema) or
name (which is the name of a field in PlayerBean class) ??
4. which sould has the <foreign-key-mapping> element , TeamBean or PlayerBean ?
 
Hussein Baghdadi
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please, this is my first week with JBoss.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your ejb-jar.xml you should have something like:
-----------------------------------------------------

<ejb-relation >
<ejb-relation-name>Team-Player</ejb-relation-name>
<ejb-relationship-role >
<ejb-relationship-role-name>Player-Belongs-To-Team</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<relationship-role-source >
<ejb-name>YourPlayerEJB</ejb-name>
</relationship-role-source>
<cmr-field >
<cmr-field-name>team</cmr-field-name>
</cmr-field>
</ejb-relationship-role>

<ejb-relationship-role >
<ejb-relationship-role-name>Team-Has-Players</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source >
<ejb-name>YourTeamEJB</ejb-name>
</relationship-role-source>
<cmr-field >
<cmr-field-name>players</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>


And in your jbosscmp-jdbc.xml you should have:
-----------------------------------------------


<ejb-relation>
<ejb-relation-name>Team-Player</ejb-relation-name>

<ejb-relationship-role>
<ejb-relationship-role-name>Player-Belongs-To-Team</ejb-relationship-role-name>
<key-fields/>

</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>Team-Has-Players</ejb-relationship-role-name>
<key-fields>
<key-field>
<field-name>id</field-name> <!--field name of primary key of Team table-->
<column-name>teamId</column-name> <!--field name of team id in Player table
</key-field>
</key-fields>
</ejb-relationship-role>
</ejb-relation>
 
reply
    Bookmark Topic Watch Topic
  • New Topic