File tree Expand file tree Collapse file tree
src/main/java/com/gabriel_torelo/game_list/entities Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .gabriel_torelo .game_list .entities ;
2+
3+ import jakarta .persistence .Embeddable ;
4+ import jakarta .persistence .JoinColumn ;
5+ import jakarta .persistence .ManyToOne ;
6+
7+ @ Embeddable
8+ public class BelongingPK {
9+
10+ @ ManyToOne
11+ @ JoinColumn (name = "game_id" )
12+ private Game game ;
13+
14+ @ ManyToOne
15+ @ JoinColumn (name = "list_id" )
16+ private GameList list ;
17+
18+ public BelongingPK (){
19+ }
20+
21+ public BelongingPK (Game game , GameList gameList ) {
22+ this .game = game ;
23+ this .list = gameList ;
24+ }
25+
26+ public Game getGame () {
27+ return game ;
28+ }
29+
30+ public void setGame (Game game ) {
31+ this .game = game ;
32+ }
33+
34+ public GameList getGameList () {
35+ return list ;
36+ }
37+
38+ public void setGameList (GameList gameList ) {
39+ this .list = gameList ;
40+ }
41+
42+ @ Override
43+ public int hashCode () {
44+ final int prime = 31 ;
45+ int result = 1 ;
46+ result = prime * result + ((game == null ) ? 0 : game .hashCode ());
47+ result = prime * result + ((list == null ) ? 0 : list .hashCode ());
48+ return result ;
49+ }
50+
51+ @ Override
52+ public boolean equals (Object obj ) {
53+ if (this == obj )
54+ return true ;
55+ if (obj == null )
56+ return false ;
57+ if (getClass () != obj .getClass ())
58+ return false ;
59+ BelongingPK other = (BelongingPK ) obj ;
60+ if (game == null ) {
61+ if (other .game != null )
62+ return false ;
63+ } else if (!game .equals (other .game ))
64+ return false ;
65+ if (list == null ) {
66+ if (other .list != null )
67+ return false ;
68+ } else if (!list .equals (other .list ))
69+ return false ;
70+ return true ;
71+ }
72+ }
You can’t perform that action at this time.
0 commit comments