Skip to content

Commit

Permalink
add cascade to employees in Department entity
Browse files Browse the repository at this point in the history
  • Loading branch information
SelimHorri committed Jan 22, 2021
1 parent b3ca2d5 commit 78833b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/pfa/pack/models/entities/Department.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Employee> employees;

public Department() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ <h2 th:case="null">No Records yet!</h2>
<td th:text="${d.departmentName}"></td>
<td th:text="${d.location.adr + ', ' + d.location.postalCode + ', ' + d.location.city}"></td>
<td><a class='btn btn-outline-warning' th:href="@{/app/admins/departments/admin-departments-edit(departmentId=${d.departmentId})}">Edit</a></td>
<td><a class='btn btn-outline-danger' th:href="@{/app/admins/departments/admin-departments-delete(departmentId=${d.departmentId})}" onClick="if (!(confirm('Do you confirm you want DELETE this department ?'))) return false" >Delete</a></td>
<td><a class='btn btn-outline-danger' th:href="@{/app/admins/departments/admin-departments-delete(departmentId=${d.departmentId})}" onClick="if (!(confirm('Do you confirm you want DELETE this department ?\n this will provoke deletion of employees related to this department'))) return false" >Delete</a></td>
</tr>
</tbody>
</table>
Expand Down

0 comments on commit 78833b4

Please sign in to comment.