Bom dia pessoal,
eu não sei porque está dando o problema abaixo quando eu tento excluir uma entidade.
Caused by: java.sql.BatchUpdateException: Entrada em lote 0 delete from tbsicf_modelo where cd_modelo='1' foi abortada. Chame getNextException para ver a causa.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2569)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1796)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2708)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 60 more
Aqui está a forma como ela está mapeada
@OneToMany(mappedBy = "marca", fetch = FetchType.EAGER,cascade=CascadeType.ALL)
private List<Modelo> modelos = new ArrayList<Modelo>();
Aqui está o método do delete
public String remover() {
try{
dao.remover(marca);
marcas = null;
}catch (Exception e) {
e.printStackTrace();
}
return "cons_marca";
}
aqui está o .remover()
public void remover(T id) {
final EntityManager entityManager = factory
.createEntityManager();
try {
entityManager.getTransaction().begin();
id = entityManager.merge(id);
entityManager.remove(id);
entityManager.getTransaction().commit();
entityManager.close();
} catch (Exception e) {
e.printStackTrace();
}
}
Alguém saberia me explicar o porquê ?