I have two entities:
Player
Team
Player is in a M:1 bidirectional relationship with Team. Player is the
owner.
Player's team property has the @ManyToOne(cascade=CascadeType.ALL)
annotation.
Now when I remove a single Player, the Team is also removed. Obviously
that's wrong when other players belong to that team, and I guess I need
to remove the cascade attribute. However, I would like the associated
team removed when the last player is removed. Is there a slick way to do
this without performing my checks to see whether the team_id is still in
PLAYER?
The tables look like this:
PLAYER
id, name, jerseynumber, team_id
TEAM
id, name, league
Regards,
John O'Conner