background image

The roster Application

<< The all Task | Entity Inheritance in the roster Application >>
<< The all Task | Entity Inheritance in the roster Application >>

The roster Application

Undeploying order
To undeploy order.ear, enter the following command:
ant undeploy
The roster Application
The roster application maintains the team rosters for players in recreational sports leagues.
The application has four components: Java Persistence API entities (Player, Team, and League),
a stateful session bean (RequestBean), an application client (RosterClient), and three helper
classes (PlayerDetails, TeamDetails, and LeagueDetails).
Functionally, roster is similar to the order application described earlier in this chapter with
three new features that order does not have: many-to-many relationships, entity inheritance,
and automatic table creation at deploytime.
Relationships in the roster Application
A recreational sports system has the following relationships:
A player can be on many teams.
A team can have many players.
A team is in exactly one league.
A league has many teams.
In roster this is reflected by the following relationships between the Player, Team, and League
entities:
There is a many-to-many relationship between Player and Team.
There is a many-to-one relationship between Team and League.
The Many-To-Many Relationship in roster
The many-to-many relationship between Player and Team is specified by using the
@ManyToMany
annotation.
In Team.java, the @ManyToMany annotation decorates the getPlayers method:
@ManyToMany
@JoinTable(
name=
"EJB_ROSTER_TEAM_PLAYER",
joinColumns=
@JoinColumn(name=
"TEAM_ID", referencedColumnName="ID"),
inverseJoinColumns=
The roster Application
The Java EE 5 Tutorial · September 2007
726