I have a Company class:
public class Company implements Serializable { .... @OneToMany (mappedBy="company", cascade=CascadeType.ALL) @JoinColumn(name="COMPANY_ID") private List<Address> addresses = new ArrayList<Address>(); ... }
public class Address implements Serializable { .... @ManyToOne private Company company; ... }
com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row: a foreign key constraint fails (`db`.`address`, CONSTRAINT `FK1ED033D44C674D5C` FOREIGN KEY (`company_id`) REFERENCES `company` (`id`))
It turned out my schema needed to be updated. I had added the CascadeType to the code but not regenerated the schema. It is working now.