I have 2 tables.
private Set<Mails> mails;
@JoinColumn(name="user_id" , referencedColumnName="id", insertable=false, updatable=false)
private Accounts accounts;
The problem probably is that the relation is defined in the wrong direction. Presuming that you have an
account table with one-to-many relation to a
account until it has associated
account to reference
ON DELETE CASCADE, you tell MySQL that it should delete a row (whose table has the foreign key) if its parent (referenced by the key) is deleted. This operation is allowed by definition because in such a case the deleted record has references to it. In contrast, a deletion is not allowed if a record has references pointing to other records from it.