Skip to content

Commit 5b3a638

Browse files
committed
ORM exercise
1 parent 3ebbfa6 commit 5b3a638

3 files changed

Lines changed: 44 additions & 47 deletions

File tree

src/main/java/org/launchcode/codingevents/models/AbstractEntity.java

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/main/java/org/launchcode/codingevents/models/Event.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
* Created by Chris Bay
1414
*/
1515
@Entity
16-
public class Event extends AbstractEntity {
17-
16+
public class Event {
17+
@Id
18+
@GeneratedValue
19+
private int id;
1820

1921
@NotBlank(message = "Name is required")
2022
@Size(min = 3, max = 50, message = "Name must be between 3 and 50 characters")
@@ -70,6 +72,27 @@ public void setType(EventType type) {
7072
this.type = type;
7173
}
7274

75+
public int getId() {
76+
return id;
77+
}
78+
79+
public void setId(int id) {
80+
this.id = id;
81+
}
82+
83+
@Override
84+
public boolean equals(Object o) {
85+
if (this == o) return true;
86+
if (o == null || getClass() != o.getClass()) return false;
87+
Event event = (Event) o;
88+
return id == event.id;
89+
}
90+
91+
@Override
92+
public int hashCode() {
93+
return Objects.hash(id);
94+
}
95+
7396
@Override
7497
public String toString() {
7598
return name;

src/main/java/org/launchcode/codingevents/models/EventCategory.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
import java.util.Objects;
99

1010
@Entity
11-
public class EventCategory extends AbstractEntity {
11+
public class EventCategory{
12+
13+
@Id
14+
@GeneratedValue
15+
private int id;
1216

1317

1418
@Size(min=3, message="Name must be at least 3 characters long")
@@ -28,11 +32,25 @@ public void setName(String name) {
2832
this.name = name;
2933
}
3034

35+
public int getId() {
36+
return id;
37+
}
3138

3239
@Override
3340
public String toString() {
3441
return name;
3542
}
3643

44+
@Override
45+
public boolean equals(Object o) {
46+
if (this == o) return true;
47+
if (o == null || getClass() != o.getClass()) return false;
48+
EventCategory that = (EventCategory) o;
49+
return id == that.id;
50+
}
3751

52+
@Override
53+
public int hashCode() {
54+
return Objects.hash(id);
55+
}
3856
}

0 commit comments

Comments
 (0)