If we use javax.persistence.CascadeType.All for deleting child records it will delete only collection of strings. Other than collection of strings in order to delete we need to useFor Example,
org.hibernate.annotations.CascadeType.DELETE_ORPHAN to delete the child records.
public class Employee {
@OneToMany(cascade = {CascadeType.ALL})
@Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
List<Department> departments;
}
0 comments:
Post a Comment