From 78833b407404dbe29d6ae00e9bcb6a509d4776e9 Mon Sep 17 00:00:00 2001 From: SelimHorri Date: Fri, 22 Jan 2021 22:54:20 +0100 Subject: [PATCH] add cascade to employees in Department entity --- src/main/java/com/pfa/pack/models/entities/Department.java | 4 +++- .../templates/admins/departments/admin-departments-list.html | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/pfa/pack/models/entities/Department.java b/src/main/java/com/pfa/pack/models/entities/Department.java index 404fea6..edea802 100644 --- a/src/main/java/com/pfa/pack/models/entities/Department.java +++ b/src/main/java/com/pfa/pack/models/entities/Department.java @@ -4,8 +4,10 @@ import java.util.Collections; import java.util.Set; +import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @@ -39,7 +41,7 @@ public final class Department implements Serializable { private Location location; @JsonIgnore - @OneToMany(mappedBy = "department") + @OneToMany(mappedBy = "department", fetch = FetchType.LAZY, cascade = CascadeType.ALL) private Set employees; public Department() { diff --git a/src/main/resources/templates/admins/departments/admin-departments-list.html b/src/main/resources/templates/admins/departments/admin-departments-list.html index 59100f0..7dd0733 100644 --- a/src/main/resources/templates/admins/departments/admin-departments-list.html +++ b/src/main/resources/templates/admins/departments/admin-departments-list.html @@ -35,7 +35,7 @@

No Records yet!

Edit - Delete + Delete