This is because when you remove the player from the team the player will no longer have a team. This violates both the repository definition and will result in a SQL error because team_id cannot be null.

The only way you can change a player’s team is to do this.

player.setPropertyValue("team", newTeam);

To help enforce this you can make the team’s players property unwritable.

I hope this makes sense. If you have any questions please leave them in the comments.