Hibernate 3.3.x
@Entity
public class User {
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@OnDelete(action = OnDeleteAction.CASCADE)
@Cascade(value = DELETE_ORPHAN)
@OrderBy
private List<Phone> phones= new ArrayList<Phone>(0);
...
}
Cascade delete is not enabled if you have some phones for a certain user. If the phone list is empty, this seems to be working fine. It fails with a foreign key violation error on the User reference from Phone. What am I missing here?