I have a Parent class pointing to a Child class:
public class Parent {
@OneToOne
private Child child;
}
public class Child {
}
Is there a way to delete a Child without getting a constraint Exception ?
Caused by: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails
P.S: I'm not entirely sure I've modeled this properly. A Parent can be pointing to one Child but an instance of a Child can be pointed to by more than one Parent. What I'd like to do is to delete a Child and have it's references among all Parents removed. Hope you understand.