java.sql.BatchUpdateException: Cannot delete or update a parent row: a foreign key constraint fails (`dblop`.`Produto`, CONSTRAINT `FK50C666D9839D162` FOREIGN KEY (`categoria_id`) REFERENCES `Categoria` (`id`))
@Entity
public class Produto {
@Id
@GeneratedValue
private Long id ;
@ManyToOne(cascade = CascadeType.ALL, fetch=FetchType.EAGER)
private Categoria categoria ;
private String nome ;
private String descricao ;
private String cor ;
private Double preco ;
// getters and setters
public void remove(T t) {
EntityManager em = new JPAUtil().getEntityManager();
em.getTransaction().begin();
em.remove(em.merge(t));
em.getTransaction().commit();
em.close();
}
Gostaria de saber pq tá dando esse erro, e como faço para deletar algo dessa tabela com esse relacionamento?
Grato!