title: Cascade type in Spring boot
body: <p>I'm a new to Spring boot.
  I'd like to know which cascade type I have to use in this case.</p>
  <p>I have an <strong>Employee</strong> class and a <strong>Departement</strong>.</p>
  <p>Many Employees can work in a Departement (So i guess it's a <strong>@ManyToOne Relation</strong>) and a Department can have one or more Employees (so it's a **@OneToMany).</p>
  <p>I want to perform some edits on the Employee class which have to be propagated to the other dependency.
  BUT if I delete one employee, I can't delete an entire Departement, so I have to just delete the Employee.</p>
  <pre><code>@Entity
  public class Department
  {
    @Column(nullable = false)
    private String name;
    @Id
    private String code;
    @Column(nullable = false)
    private String address;
    @Column(unique = true, nullable = false)
    private String website;
    @Column(unique = true, nullable = false)
    private String cellNumber;
  
  
    @JsonIgnore
    @OneToMany(mappedBy = &quot;department&quot;)
    private Set&lt;Employee&gt; emplpoyee;
    
    //constructors, getters and setters
  }
  </code></pre>
  <p>Here is the <strong>Employee</strong> Class</p>
  <pre><code>public class Employee
  {
    @Id
    private String SSN;
    @Column(nullable = false)
    private String name;
  
    @Column(nullable = false)
    private String lastname;
  
    @Column(nullable = false)
    private String username;
  
    @Column(nullable = false)
    private String gender;
  
    @Column(unique = true, nullable = false)
    private String email;
  
    @Column(nullable = false)
    private String password;
  
    @Column(nullable = false)
    private String role;
  
    @ManyToOne(cascade = CascadeType.???, fetch = FetchType.LAZY)
    @JoinTable(
          name = &quot;employee_works_in_dept&quot;,
          joinColumns = {@JoinColumn(name = &quot;employee_SSN&quot;)},
          inverseJoinColumns = {@JoinColumn(name = &quot;dept_code&quot;)}
  )
  private Department department;
  }
  </code></pre>
  <p>What is that I have to replace with ??</p>
  <p>I tried with CascadeType.ALL but it also deletes the Entire Department</p>