package com.gntics.footballmanager.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.validator.constraints.NotEmpty;

@Entity
@Table(name = "player")
public class Player {
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;

	@Column(name = "first_name")
	@NotEmpty
	private String firstname;
	
	@Column(name = "last_name")
	@NotEmpty
	private String lastname;
	
	@Column(name = "role")
	@NotEmpty
	private String role;
	
	@Column(name = "age")
	@NotEmpty
	private Integer age;
	
	@ManyToOne
    @JoinColumn(name = "owner_id")
    private Team team;

	// Getters and Setters
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}

	public String getFirstname() {
		return firstname;
	}
	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}
	public String getLastname() {
		return lastname;
	}
	public void setLastname(String lastname) {
		this.lastname = lastname;
	}
	public String getRole() {
		return role;
	}
	public void setRole(String role) {
		this.role = role;
	}
	public Integer getAge() {
		return age;
	}
	public void setAge(Integer age) {
		this.age = age;
	}

	public Team getTeam() {
		return team;
	}
	public void setTeam(Team team) {
		this.team = team;
	}
	
}

@@ -317,16 +317,143 @@
 e.Table;
+%0Aimport javax.validation.constraints.Max;%0Aimport javax.validation.constraints.Min;%0Aimport javax.validation.constraints.NotNull;
 %0A%0Aimport
@@ -853,37 +853,56 @@
 e = %22age%22)%0A%09@Not
-Empty
+Null%0A%09@Min(0)%0A%09@Max(100)
 %0A%09private Intege
@@ -950,13 +950,12 @@
  = %22
-owner
+team
 _id%22
@@ -980,16 +980,283 @@
  team;%0A%0A
+%09// Constructors%0A%09public Player() %7B%7D // hibernate require a default constructor%0A%09%0A%09public Player(String firstname, String lastname, Integer age, String role) %7B%0A%09%09this.firstname = firstname;%0A%09%09this.lastname  = lastname;%0A%09%09this.age%09   = age;%0A%09%09this.role%09   = role;%0A%09%7D%0A%0A
 %09// Gett

update Player model