Author | SHA1 | Message | Date |
---|---|---|---|
|
9c7f493956 | nicer entities using lombok | 4 years ago |
|
6e3ea3d7c8 | refactoring | 4 years ago |
@ -1,42 +1,29 @@ | |||||
package app.data.entity; | package app.data.entity; | ||||
import javax.persistence.GeneratedValue; | |||||
import javax.persistence.Id; | |||||
import javax.persistence.MappedSuperclass; | |||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import javax.persistence.*; | |||||
@Getter | |||||
@Setter | |||||
@MappedSuperclass | @MappedSuperclass | ||||
public abstract class AbstractEntity { // TODO: Use this in your own entities (adapt annotations and equals()) | |||||
public abstract class AbstractEntity { | |||||
@Id | @Id | ||||
@GeneratedValue | |||||
@GeneratedValue(strategy = GenerationType.IDENTITY) | |||||
@Column(name = "id", nullable = false) | |||||
private Integer id; | private Integer id; | ||||
public Integer getId() { | |||||
return id; | |||||
} | |||||
public void setId(Integer id) { | |||||
this.id = id; | |||||
} | |||||
@Override | @Override | ||||
public int hashCode() { | public int hashCode() { | ||||
if (id != null) { | |||||
return id.hashCode(); | |||||
} | |||||
return super.hashCode(); | |||||
return id != null ? id.hashCode() : super.hashCode(); | |||||
} | } | ||||
@Override | @Override | ||||
public boolean equals(Object obj) { | public boolean equals(Object obj) { | ||||
if (!(obj instanceof AbstractEntity)) { | |||||
return false; // null or other class | |||||
} | |||||
if (!(obj instanceof AbstractEntity)) return false; // null or other class | |||||
AbstractEntity other = (AbstractEntity) obj; | AbstractEntity other = (AbstractEntity) obj; | ||||
if (id != null) { | |||||
return id.equals(other.id); | |||||
} | |||||
return super.equals(other); | |||||
return id != null ? id.equals(other.id) : super.equals(other); | |||||
} | } | ||||
} | } |
@ -1,78 +1,36 @@ | |||||
package app.data.entity; | package app.data.entity; | ||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import javax.persistence.*; | import javax.persistence.*; | ||||
import java.util.Objects; | |||||
@Getter | |||||
@Setter | |||||
@Entity | @Entity | ||||
@Table(name = "game", schema = "public", catalog = "chessleague") | |||||
public class Game { | |||||
private Integer id; | |||||
private Boolean player1IsWhite; | |||||
private Integer result; | |||||
@Table(name = "game", | |||||
schema = "public", | |||||
catalog = "chessleague") | |||||
public class Game extends AbstractEntity { | |||||
@ManyToOne(cascade = CascadeType.DETACH) | |||||
@JoinColumn(name = "match", | |||||
referencedColumnName = "id", | |||||
nullable = false) | |||||
private Match match; | private Match match; | ||||
private GameInfo gameInfo; | |||||
@Id | |||||
@GeneratedValue(strategy = GenerationType.IDENTITY) | |||||
@Column(name = "id", nullable = false) | |||||
public Integer getId() { | |||||
return id; | |||||
} | |||||
public void setId(Integer id) { | |||||
this.id = id; | |||||
} | |||||
@Basic | @Basic | ||||
@Column(name = "player1_is_white", nullable = false) | |||||
public Boolean getPlayer1IsWhite() { | |||||
return player1IsWhite; | |||||
} | |||||
public void setPlayer1IsWhite(Boolean player1IsWhite) { | |||||
this.player1IsWhite = player1IsWhite; | |||||
} | |||||
@Column(name = "player1_is_white", | |||||
nullable = false) | |||||
private Boolean player1IsWhite; | |||||
@Basic | @Basic | ||||
@Column(name = "result", nullable = false) | |||||
public Integer getResult() { | |||||
return result; | |||||
} | |||||
public void setResult(Integer result) { | |||||
this.result = result; | |||||
} | |||||
@Override | |||||
public boolean equals(Object o) { | |||||
if (this == o) return true; | |||||
if (o == null || getClass() != o.getClass()) return false; | |||||
Game that = (Game) o; | |||||
return Objects.equals(id, that.id) && Objects.equals(player1IsWhite, that.player1IsWhite) && Objects.equals(result, that.result); | |||||
} | |||||
@Override | |||||
public int hashCode() { | |||||
return Objects.hash(id, player1IsWhite, result); | |||||
} | |||||
@ManyToOne(cascade=CascadeType.DETACH) | |||||
@JoinColumn(name = "match", referencedColumnName = "id", nullable = false) | |||||
public Match getMatch() { | |||||
return match; | |||||
} | |||||
public void setMatch(Match match) { | |||||
this.match = match; | |||||
} | |||||
@Column(name = "result", | |||||
nullable = false) | |||||
private Integer result; | |||||
@OneToOne(cascade = CascadeType.ALL) | @OneToOne(cascade = CascadeType.ALL) | ||||
@JoinColumn(name = "info", referencedColumnName = "id") | |||||
public GameInfo getGameInfo() { | |||||
return gameInfo; | |||||
} | |||||
public void setGameInfo(GameInfo gameInfo) { | |||||
this.gameInfo = gameInfo; | |||||
} | |||||
@JoinColumn(name = "info", | |||||
referencedColumnName = "id") | |||||
private GameInfo gameInfo; | |||||
} | } |
@ -1,176 +1,69 @@ | |||||
package app.data.entity; | package app.data.entity; | ||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import javax.persistence.*; | import javax.persistence.*; | ||||
import java.util.Objects; | |||||
@Getter | |||||
@Setter | |||||
@Entity | @Entity | ||||
@Table(name = "game_info", schema = "public", catalog = "chessleague") | |||||
public class GameInfo { | |||||
private Integer id; | |||||
private String chessComId; | |||||
private Game game; | |||||
private String timeControl; | |||||
private String fen; | |||||
private Long endTime; | |||||
private String pgn; | |||||
private Boolean rated; | |||||
private String timeClass; | |||||
private String rules; | |||||
private Integer whiteRating; | |||||
private Integer blackRating; | |||||
private String whiteResult; | |||||
private String blackResult; | |||||
@Id | |||||
@GeneratedValue(strategy = GenerationType.IDENTITY) | |||||
@Column(name = "id", nullable = false) | |||||
public Integer getId() { | |||||
return id; | |||||
} | |||||
@Table(name = "game_info", | |||||
schema = "public", | |||||
catalog = "chessleague") | |||||
public class GameInfo extends AbstractEntity { | |||||
public void setId(Integer id) { | |||||
this.id = id; | |||||
} | |||||
@OneToOne(mappedBy = "gameInfo", | |||||
cascade = CascadeType.DETACH) | |||||
private Game game; | |||||
@Basic | @Basic | ||||
@Column(name = "chess_com_id", length = -1) | |||||
public String getChessComId() { | |||||
return chessComId; | |||||
} | |||||
public void setChessComId(String chessComId) { | |||||
this.chessComId = chessComId; | |||||
} | |||||
@Column(name = "chess_com_id") | |||||
private String chessComId; | |||||
@Basic | @Basic | ||||
@Column(name = "time_control", nullable = false) | |||||
public String getTimeControl() { | |||||
return timeControl; | |||||
} | |||||
public void setTimeControl(String format) { | |||||
this.timeControl = format; | |||||
} | |||||
@Column(name = "time_control", | |||||
nullable = false) | |||||
private String timeControl; | |||||
@Basic | @Basic | ||||
@Column(name = "fen", nullable = false) | |||||
public String getFen() { | |||||
return fen; | |||||
} | |||||
public void setFen(String fen) { | |||||
this.fen = fen; | |||||
} | |||||
@Override | |||||
public boolean equals(Object o) { | |||||
if (this == o) return true; | |||||
if (o == null || getClass() != o.getClass()) return false; | |||||
GameInfo that = (GameInfo) o; | |||||
return Objects.equals(id, that.id) && Objects.equals(chessComId, that.chessComId) && Objects.equals(timeControl, that.timeControl); | |||||
} | |||||
@Override | |||||
public int hashCode() { | |||||
return Objects.hash(id, chessComId, timeControl); | |||||
} | |||||
@OneToOne(mappedBy = "gameInfo", cascade = CascadeType.DETACH) | |||||
public Game getGame() { | |||||
return game; | |||||
} | |||||
public void setGame(Game game) { | |||||
this.game = game; | |||||
} | |||||
@Column(name = "fen", | |||||
nullable = false) | |||||
private String fen; | |||||
@Basic | @Basic | ||||
@Column(name = "end_time") // TODO: make not nullable (you need the end times of the first matchday for that...) | @Column(name = "end_time") // TODO: make not nullable (you need the end times of the first matchday for that...) | ||||
public Long getEndTime() { | |||||
return endTime; | |||||
} | |||||
public void setEndTime(Long endTime) { | |||||
this.endTime = endTime; | |||||
} | |||||
private Long endTime; | |||||
@Basic | @Basic | ||||
@Column(name = "pgn") | @Column(name = "pgn") | ||||
public String getPgn() { | |||||
return pgn; | |||||
} | |||||
public void setPgn(String pgn) { | |||||
this.pgn = pgn; | |||||
} | |||||
private String pgn; | |||||
@Basic | @Basic | ||||
@Column(name = "rated") | @Column(name = "rated") | ||||
public Boolean getRated() { | |||||
return rated; | |||||
} | |||||
public void setRated(Boolean rated) { | |||||
this.rated = rated; | |||||
} | |||||
private Boolean rated; | |||||
@Basic | @Basic | ||||
@Column(name = "time_class") | @Column(name = "time_class") | ||||
public String getTimeClass() { | |||||
return timeClass; | |||||
} | |||||
public void setTimeClass(String timeClass) { | |||||
this.timeClass = timeClass; | |||||
} | |||||
private String timeClass; | |||||
@Basic | @Basic | ||||
@Column(name = "rules") | @Column(name = "rules") | ||||
public String getRules() { | |||||
return rules; | |||||
} | |||||
public void setRules(String rules) { | |||||
this.rules = rules; | |||||
} | |||||
private String rules; | |||||
@Basic | @Basic | ||||
@Column(name = "white_rating") | @Column(name = "white_rating") | ||||
public Integer getWhiteRating() { | |||||
return whiteRating; | |||||
} | |||||
public void setWhiteRating(Integer whiteRating) { | |||||
this.whiteRating = whiteRating; | |||||
} | |||||
private Integer whiteRating; | |||||
@Basic | @Basic | ||||
@Column(name = "black_rating") | @Column(name = "black_rating") | ||||
public Integer getBlackRating() { | |||||
return blackRating; | |||||
} | |||||
public void setBlackRating(Integer blackRating) { | |||||
this.blackRating = blackRating; | |||||
} | |||||
private Integer blackRating; | |||||
@Basic | @Basic | ||||
@Column(name = "white_result") | @Column(name = "white_result") | ||||
public String getWhiteResult() { | |||||
return whiteResult; | |||||
} | |||||
public void setWhiteResult(String whiteResult) { | |||||
this.whiteResult = whiteResult; | |||||
} | |||||
private String whiteResult; | |||||
@Basic | @Basic | ||||
@Column(name = "black_result") | @Column(name = "black_result") | ||||
public String getBlackResult() { | |||||
return blackResult; | |||||
} | |||||
public void setBlackResult(String blackResult) { | |||||
this.blackResult = blackResult; | |||||
} | |||||
private String blackResult; | |||||
} | } |
@ -1,78 +1,40 @@ | |||||
package app.data.entity; | package app.data.entity; | ||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import javax.persistence.*; | import javax.persistence.*; | ||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.Objects; | |||||
@Getter | |||||
@Setter | |||||
@Entity | @Entity | ||||
@Table(name = "match", schema = "public", catalog = "chessleague") | |||||
public class Match { | |||||
private Integer id; | |||||
private Collection<Game> games; | |||||
private Player player1; | |||||
private Player player2; | |||||
@Table(name = "match", | |||||
schema = "public", | |||||
catalog = "chessleague") | |||||
public class Match extends AbstractEntity { | |||||
@ManyToOne(cascade = CascadeType.DETACH) | |||||
@JoinColumn(name = "matchday", | |||||
referencedColumnName = "id", | |||||
nullable = false) | |||||
private Matchday matchday; | private Matchday matchday; | ||||
@Id | |||||
@GeneratedValue(strategy = GenerationType.IDENTITY) | |||||
@Column(name = "id", nullable = false) | |||||
public Integer getId() { | |||||
return id; | |||||
} | |||||
public void setId(Integer id) { | |||||
this.id = id; | |||||
} | |||||
@Override | |||||
public boolean equals(Object o) { | |||||
if (this == o) return true; | |||||
if (o == null || getClass() != o.getClass()) return false; | |||||
Match that = (Match) o; | |||||
return Objects.equals(id, that.id); | |||||
} | |||||
@Override | |||||
public int hashCode() { | |||||
return Objects.hash(id); | |||||
} | |||||
@OneToMany(mappedBy = "match", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) | |||||
public Collection<Game> getGames() { | |||||
return games; | |||||
} | |||||
public void setGames(Collection<Game> games) { | |||||
this.games = games; | |||||
} | |||||
@ManyToOne(cascade=CascadeType.DETACH) | |||||
@JoinColumn(name = "player1", referencedColumnName = "id", nullable = false) | |||||
public Player getPlayer1() { | |||||
return player1; | |||||
} | |||||
public void setPlayer1(Player player1) { | |||||
this.player1 = player1; | |||||
} | |||||
@ManyToOne(cascade=CascadeType.DETACH) | |||||
@JoinColumn(name = "player2", referencedColumnName = "id", nullable = false) | |||||
public Player getPlayer2() { | |||||
return player2; | |||||
} | |||||
public void setPlayer2(Player player2) { | |||||
this.player2 = player2; | |||||
} | |||||
@ManyToOne(cascade = CascadeType.DETACH) | |||||
@JoinColumn(name = "player1", | |||||
referencedColumnName = "id", | |||||
nullable = false) | |||||
private Player player1; | |||||
@ManyToOne(cascade=CascadeType.DETACH) | |||||
@JoinColumn(name = "matchday", referencedColumnName = "id", nullable = false) | |||||
public Matchday getMatchday() { | |||||
return matchday; | |||||
} | |||||
@ManyToOne(cascade = CascadeType.DETACH) | |||||
@JoinColumn(name = "player2", | |||||
referencedColumnName = "id", | |||||
nullable = false) | |||||
private Player player2; | |||||
public void setMatchday(Matchday matchday) { | |||||
this.matchday = matchday; | |||||
} | |||||
@OneToMany(mappedBy = "match", | |||||
fetch = FetchType.EAGER, | |||||
cascade = CascadeType.ALL, | |||||
orphanRemoval = true) | |||||
private Collection<Game> games; | |||||
} | } |
@ -1,67 +1,32 @@ | |||||
package app.data.entity; | package app.data.entity; | ||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import javax.persistence.*; | import javax.persistence.*; | ||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.Objects; | |||||
@Getter | |||||
@Setter | |||||
@Entity | @Entity | ||||
@Table(name = "matchday", schema = "public", catalog = "chessleague") | |||||
public class Matchday { | |||||
private Integer id; | |||||
private Integer number; | |||||
private Collection<Match> matches; | |||||
@Table(name = "matchday", | |||||
schema = "public", | |||||
catalog = "chessleague") | |||||
public class Matchday extends AbstractEntity { | |||||
@ManyToOne(cascade = CascadeType.DETACH) | |||||
@JoinColumn(name = "season", | |||||
referencedColumnName = "id", | |||||
nullable = false) | |||||
private Season season; | 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 | @Basic | ||||
@Column(name = "number", nullable = false) | @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, cascade = CascadeType.ALL) | |||||
public Collection<Match> getMatches() { | |||||
return matches; | |||||
} | |||||
public void setMatches(Collection<Match> matches) { | |||||
this.matches = matches; | |||||
} | |||||
@ManyToOne(cascade=CascadeType.DETACH) | |||||
@JoinColumn(name = "season", referencedColumnName = "id", nullable = false) | |||||
public Season getSeason() { | |||||
return season; | |||||
} | |||||
private Integer number; | |||||
public void setSeason(Season season) { | |||||
this.season = season; | |||||
} | |||||
@OneToMany(mappedBy = "matchday", | |||||
fetch = FetchType.EAGER, | |||||
cascade = CascadeType.ALL, | |||||
orphanRemoval = true) | |||||
private Collection<Match> matches; | |||||
} | } |
@ -1,89 +1,39 @@ | |||||
package app.data.entity; | package app.data.entity; | ||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import javax.persistence.*; | import javax.persistence.*; | ||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.Objects; | |||||
@Getter | |||||
@Setter | |||||
@Entity | @Entity | ||||
@Table(name = "player", schema = "public", catalog = "chessleague") | |||||
public class Player { | |||||
private Integer id; | |||||
private String name; | |||||
private String nickname; | |||||
private Collection<Match> matchesAsPlayer1; | |||||
private Collection<Match> matchesAsPlayer2; | |||||
private PlayerInfo playerInfo; | |||||
@Id | |||||
@GeneratedValue(strategy = GenerationType.IDENTITY) | |||||
@Column(name = "id", nullable = false) | |||||
public Integer getId() { | |||||
return id; | |||||
} | |||||
public void setId(Integer id) { | |||||
this.id = id; | |||||
} | |||||
@Table(name = "player", | |||||
schema = "public", | |||||
catalog = "chessleague") | |||||
public class Player extends AbstractEntity { | |||||
@Basic | @Basic | ||||
@Column(name = "name", nullable = false, length = -1) | |||||
public String getName() { | |||||
return name; | |||||
} | |||||
public void setName(String name) { | |||||
this.name = name; | |||||
} | |||||
@Column(name = "name", | |||||
nullable = false) | |||||
private String name; | |||||
@Basic | @Basic | ||||
@Column(name = "nickname", nullable = false, length = -1) | |||||
public String getNickname() { | |||||
return nickname; | |||||
} | |||||
public void setNickname(String nickname) { | |||||
this.nickname = nickname; | |||||
} | |||||
@Override | |||||
public boolean equals(Object o) { | |||||
if (this == o) return true; | |||||
if (o == null || getClass() != o.getClass()) return false; | |||||
Player that = (Player) o; | |||||
return Objects.equals(id, that.id) && Objects.equals(name, that.name) && Objects.equals(nickname, that.nickname); | |||||
} | |||||
@Override | |||||
public int hashCode() { | |||||
return Objects.hash(id, name, nickname); | |||||
} | |||||
@OneToMany(mappedBy = "player1", cascade = CascadeType.DETACH) | |||||
public Collection<Match> getMatchesAsPlayer1() { | |||||
return matchesAsPlayer1; | |||||
} | |||||
public void setMatchesAsPlayer1(Collection<Match> matchesAsPlayer1) { | |||||
this.matchesAsPlayer1 = matchesAsPlayer1; | |||||
} | |||||
@Column(name = "nickname", | |||||
nullable = false) | |||||
private String nickname; | |||||
@OneToMany(mappedBy = "player2", cascade = CascadeType.DETACH) | |||||
public Collection<Match> getMatchesAsPlayer2() { | |||||
return matchesAsPlayer2; | |||||
} | |||||
@OneToMany(mappedBy = "player1", | |||||
cascade = CascadeType.DETACH) | |||||
private Collection<Match> matchesAsPlayer1; | |||||
public void setMatchesAsPlayer2(Collection<Match> matchesAsPlayer2) { | |||||
this.matchesAsPlayer2 = matchesAsPlayer2; | |||||
} | |||||
@OneToMany(mappedBy = "player2", | |||||
cascade = CascadeType.DETACH) | |||||
private Collection<Match> matchesAsPlayer2; | |||||
@OneToOne(cascade = CascadeType.ALL) | @OneToOne(cascade = CascadeType.ALL) | ||||
@JoinColumn(name = "info", referencedColumnName = "id") | |||||
public PlayerInfo getPlayerInfo() { | |||||
return playerInfo; | |||||
} | |||||
public void setPlayerInfo(PlayerInfo playerInfo) { | |||||
this.playerInfo = playerInfo; | |||||
} | |||||
} | |||||
@JoinColumn(name = "info", | |||||
referencedColumnName = "id") | |||||
private PlayerInfo playerInfo; | |||||
} |
@ -1,55 +1,23 @@ | |||||
package app.data.entity; | package app.data.entity; | ||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import javax.persistence.*; | import javax.persistence.*; | ||||
import java.util.Objects; | |||||
@Getter | |||||
@Setter | |||||
@Entity | @Entity | ||||
@Table(name = "player_info", schema = "public", catalog = "chessleague") | |||||
public class PlayerInfo { | |||||
private Integer id; | |||||
private String url; | |||||
private Player player; | |||||
@Table(name = "player_info", | |||||
schema = "public", | |||||
catalog = "chessleague") | |||||
public class PlayerInfo extends AbstractEntity { | |||||
@Id | |||||
@GeneratedValue(strategy = GenerationType.IDENTITY) | |||||
@Column(name = "id", nullable = false) | |||||
public Integer getId() { | |||||
return id; | |||||
} | |||||
public void setId(Integer id) { | |||||
this.id = id; | |||||
} | |||||
@OneToOne(mappedBy = "playerInfo", | |||||
cascade = CascadeType.DETACH) | |||||
private Player player; | |||||
@Basic | @Basic | ||||
@Column(name = "url", length = -1) | |||||
public String getUrl() { | |||||
return url; | |||||
} | |||||
public void setUrl(String url) { | |||||
this.url = url; | |||||
} | |||||
@Override | |||||
public boolean equals(Object o) { | |||||
if (this == o) return true; | |||||
if (o == null || getClass() != o.getClass()) return false; | |||||
PlayerInfo that = (PlayerInfo) o; | |||||
return Objects.equals(id, that.id) && Objects.equals(url, that.url); | |||||
} | |||||
@Override | |||||
public int hashCode() { | |||||
return Objects.hash(id, url); | |||||
} | |||||
@OneToOne(mappedBy = "playerInfo", cascade = CascadeType.DETACH) | |||||
public Player getPlayer() { | |||||
return player; | |||||
} | |||||
public void setPlayer(Player player) { | |||||
this.player = player; | |||||
} | |||||
@Column(name = "url") | |||||
private String url; | |||||
} | } |
@ -1,68 +1,31 @@ | |||||
package app.data.entity; | package app.data.entity; | ||||
import lombok.Getter; | |||||
import lombok.Setter; | |||||
import javax.persistence.*; | import javax.persistence.*; | ||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.Objects; | |||||
@Getter | |||||
@Setter | |||||
@Entity | @Entity | ||||
@Table(name = "season", schema = "public", catalog = "chessleague") | |||||
public class Season { | |||||
private Integer id; | |||||
private Integer yearStart; | |||||
private Integer yearEnd; | |||||
private Collection<Matchday> matchdays; | |||||
@Id | |||||
@GeneratedValue(strategy = GenerationType.IDENTITY) | |||||
@Column(name = "id", nullable = false) | |||||
public Integer getId() { | |||||
return id; | |||||
} | |||||
public void setId(Integer id) { | |||||
this.id = id; | |||||
} | |||||
@Table(name = "season", | |||||
schema = "public", | |||||
catalog = "chessleague") | |||||
public class Season extends AbstractEntity { | |||||
@Basic | @Basic | ||||
@Column(name = "year_start", nullable = false) | |||||
public Integer getYearStart() { | |||||
return yearStart; | |||||
} | |||||
public void setYearStart(Integer yearStart) { | |||||
this.yearStart = yearStart; | |||||
} | |||||
@Column(name = "year_start", | |||||
nullable = false) | |||||
private Integer yearStart; | |||||
@Basic | @Basic | ||||
@Column(name = "year_end", nullable = false) | |||||
public Integer getYearEnd() { | |||||
return yearEnd; | |||||
} | |||||
public void setYearEnd(Integer yearEnd) { | |||||
this.yearEnd = yearEnd; | |||||
} | |||||
@Override | |||||
public boolean equals(Object o) { | |||||
if (this == o) return true; | |||||
if (o == null || getClass() != o.getClass()) return false; | |||||
Season that = (Season) o; | |||||
return Objects.equals(id, that.id) && Objects.equals(yearStart, that.yearStart) && Objects.equals(yearEnd, that.yearEnd); | |||||
} | |||||
@Override | |||||
public int hashCode() { | |||||
return Objects.hash(id, yearStart, yearEnd); | |||||
} | |||||
@OneToMany(mappedBy = "season", cascade = CascadeType.ALL) | |||||
public Collection<Matchday> getMatchdays() { | |||||
return matchdays; | |||||
} | |||||
public void setMatchdays(Collection<Matchday> matchdays) { | |||||
this.matchdays = matchdays; | |||||
} | |||||
@Column(name = "year_end", | |||||
nullable = false) | |||||
private Integer yearEnd; | |||||
@OneToMany(mappedBy = "season", | |||||
cascade = CascadeType.ALL, | |||||
orphanRemoval = true) | |||||
private Collection<Matchday> matchdays; | |||||
} | } |