Skip to content

Commit

Permalink
feat: Updated entities
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoJavaDev committed Oct 14, 2024
1 parent 10ea64c commit 5c07e85
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/main/java/pl/ateam/disasteralerts/disasteralert/Alert.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package pl.ateam.disasteralerts.disasteralert;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand All @@ -25,15 +28,12 @@ class Alert {
@GeneratedValue
private UUID id;

@Column(nullable = false)
private DisasterType type;
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private Disaster disaster;

@Column(nullable = false)
private String location;
private String description;

@Column(nullable = false)
private Instant creationDate;

@Column(nullable = false)
private DisasterStatus status;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.Instant;
import java.util.List;
import java.util.UUID;

@Entity
Expand Down Expand Up @@ -41,4 +43,7 @@ class Disaster {

@Column(nullable = false)
private DisasterStatus status;

@OneToMany
private List<Alert> alerts;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package pl.ateam.disasteralerts.disasteralert;

enum DisasterStatus {
ACTIVE, FINISHED
ACTIVE, FINISHED, FAKE
}

0 comments on commit 5c07e85

Please sign in to comment.