Skip to content

Commit 8620bd5

Browse files
committed
cria classe 'Belonging' com ORM 'jakarta'
1 parent b7a9488 commit 8620bd5

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.gabriel_torelo.game_list.entities;
2+
3+
import jakarta.persistence.EmbeddedId;
4+
import jakarta.persistence.Entity;
5+
import jakarta.persistence.Table;
6+
7+
@Entity
8+
@Table(name = "tb_belonging")
9+
public class Belonging {
10+
11+
@EmbeddedId
12+
private BelongingPK id = new BelongingPK();
13+
private Integer position;
14+
15+
public Belonging() {
16+
}
17+
18+
public Belonging(Game game, GameList list, Integer position) {
19+
id.setGame(game);
20+
id.setGameList(list);
21+
this.position = position;
22+
}
23+
24+
public BelongingPK getId() {
25+
return id;
26+
}
27+
28+
public void setId(BelongingPK id) {
29+
this.id = id;
30+
}
31+
32+
public Integer getPosition() {
33+
return position;
34+
}
35+
36+
public void setPosition(Integer position) {
37+
this.position = position;
38+
}
39+
40+
@Override
41+
public int hashCode() {
42+
final int prime = 31;
43+
int result = 1;
44+
result = prime * result + ((id == null) ? 0 : id.hashCode());
45+
return result;
46+
}
47+
48+
@Override
49+
public boolean equals(Object obj) {
50+
if (this == obj)
51+
return true;
52+
if (obj == null)
53+
return false;
54+
if (getClass() != obj.getClass())
55+
return false;
56+
Belonging other = (Belonging) obj;
57+
if (id == null) {
58+
if (other.id != null)
59+
return false;
60+
} else if (!id.equals(other.id))
61+
return false;
62+
return true;
63+
}
64+
}

0 commit comments

Comments
 (0)