我有一个带有员工对象和地址对象的视图实体对象。一个视图有一个员工列表。员工有一个地址列表。我想删除该员工。我收到一个抱怨删除视图的约束。视图应该保留,但视图和员工之间的关系应该消失。地址也应该没了。谁能告诉我如何设置我的 JPA 来处理这种情况?或者我应该以编程方式进行。(先找到所有视图,然后从视图中删除员工)。
View {
@OneToMany(targetEntity = Employee.class, orphanRemoval = true)
@JoinTable(name = "View_Employee")
protected List<Employee> employees;
}
Employee {
@CascadeOnDelete
@OneToMany(targetEntity = Address.class, orphanRemoval = true,fetch=FetchType.EAGER)
@JoinTable(name = "Employee_Address")
@XmlElement(required = true)
@OrderColumn
protected List<Address> address;
}
Address{
nothing of interest, no ties to view or employee
}