package app.data.entity;
|
|
|
|
import javax.persistence.*;
|
|
import java.util.Collection;
|
|
import java.util.Objects;
|
|
|
|
@Entity
|
|
@Table(name = "matchday", schema = "public", catalog = "chessleague")
|
|
public class Matchday {
|
|
private Integer id;
|
|
private Integer number;
|
|
private Collection<Match> matches;
|
|
private Season season;
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
@Column(name = "id", nullable = false)
|
|
public Integer getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(Integer id) {
|
|
this.id = id;
|
|
}
|
|
|
|
@Basic
|
|
@Column(name = "number", nullable = false)
|
|
public Integer getNumber() {
|
|
return number;
|
|
}
|
|
|
|
public void setNumber(Integer number) {
|
|
this.number = number;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) return true;
|
|
if (o == null || getClass() != o.getClass()) return false;
|
|
Matchday that = (Matchday) o;
|
|
return Objects.equals(id, that.id) && Objects.equals(number, that.number);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return Objects.hash(id, number);
|
|
}
|
|
|
|
@OneToMany(mappedBy = "matchday", fetch = FetchType.EAGER)
|
|
public Collection<Match> getMatches() {
|
|
return matches;
|
|
}
|
|
|
|
public void setMatches(Collection<Match> matches) {
|
|
this.matches = matches;
|
|
}
|
|
|
|
@ManyToOne(cascade=CascadeType.ALL)
|
|
@JoinColumn(name = "season", referencedColumnName = "id", nullable = false)
|
|
public Season getSeason() {
|
|
return season;
|
|
}
|
|
|
|
public void setSeason(Season season) {
|
|
this.season = season;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return number.toString();
|
|
}
|
|
}
|