我有兩個具有單向'ManyToOne'關係的實體類'User'和'Department',如下所示。如何級聯具有單向'ManyToOne'關係的刪除實體與JPA
public class User{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "DEPARTMENT_ID", nullable = true)
private Department department;
}
public class Department{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
}
如果我想刪除一些用戶和級聯刪除引用部門如果沒有任何用戶參考系,有JPA的任何功能使用嗎?
您是否解決了您的問題? –