package com.gntics.footballmanager.model;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.validator.constraints.NotEmpty;


@Entity
@Table(name = "team")
public class Team {

	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
	
	@Column(name = "name")
	@NotEmpty
	private String name;

	@OneToMany(cascade = CascadeType.ALL)
	private Set<Player> players;
	
	
	// Getters and Setters
	public void setId(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Set<Player> getPlayers() {
		return players;
	}

	public void setPlayers(Set<Player> players) {
		this.players = players;
	}
	
	public boolean isNew() {
        return (this.id == null);
    }

}

@@ -36,16 +36,42 @@
 model;%0A%0A
+import java.util.HashSet;%0A
 import j
@@ -189,16 +189,52 @@
 Entity;%0A
+import javax.persistence.FetchType;%0A
 import j
@@ -697,41 +697,314 @@
 .ALL
-)%0A%09private Set%3CPlayer%3E players;%0A%09
+, mappedBy = %22team%22, fetch = FetchType.EAGER)%0A%09private Set%3CPlayer%3E players;%0A%09%0A%09// Methods%0A%09public void addPlayer(Player player)%7B%0A%09%09Set%3CPlayer%3E players = getPlayers();%0A%09%09players.add(player);%0A%09%09player.setTeam(this);%0A%09%7D%0A%09%0A%09// Constructor%0A%09public Team() %7B %7D%0A%09%0A%09public Team(String name) %7B%0A%09%09this.name = name;%0A%09%7D
 %0A%09%0A%09
@@ -1286,23 +1286,124 @@
 s() %7B%0A%09%09
+if (this.players == null) %7B%0A            this.players = new HashSet%3CPlayer%3E();%0A        %7D%0A        
 return 
+this.
 players;

update Team model