Guest User

Untitled

a guest
Oct 24th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. java.lang.IllegalArgumentException: attempt to create delete event with null entity
  2. at org.hibernate.event.spi.DeleteEvent.<init>(DeleteEvent.java:48)
  3. at org.hibernate.internal.SessionImpl.delete(SessionImpl.java:896)
  4. at br.com.drogaria.dao.GenericDAO.excluir(GenericDAO.java:48)
  5. at br.com.drogaria.bean.FabricanteBean.excluir(FabricanteBean.java:62)
  6.  
  7. public void excluir(Entidade entidade) {
  8. Session sessao = HibernateUtil.getFabricaDeSessoes().openSession();
  9. Transaction transacao = null;
  10.  
  11. try {
  12. transacao = sessao.beginTransaction();
  13. sessao.delete(entidade);
  14. transacao.commit();
  15. } catch (RuntimeException erro) {
  16. if (transacao != null) {
  17. transacao.rollback();
  18. }
  19. throw erro;
  20. } finally {
  21. sessao.close();
  22. }
  23. }
  24.  
  25. public void excluir(ActionEvent evento) {
  26. try {
  27. this.fabricante = (Fabricante) evento.getComponent().getAttributes().get("fabricanteSelecionado");
  28.  
  29. FabricanteDAO fabricanteDAO = new FabricanteDAO();
  30. //this.fabricante = fabricanteDAO.buscar(fabricante.getCodigo());
  31.  
  32. fabricanteDAO.excluir(fabricante);
  33. this.fabricantes = fabricanteDAO.listar();
  34.  
  35. Messages.addGlobalInfo("Fabricante excluído com sucesso!");
  36. } catch (RuntimeException erro) {
  37. Messages.addGlobalError("Ocorreu um erro ao tentar excluir um Fabricante.");
  38. erro.printStackTrace();
  39. }
  40.  
  41. <p:commandButton icon="ui-icon-trash" actionListener="#{fabricanteBean.excluir}"
  42. update=":mensagem :formListagem:tabela" title="Excluir">
  43. <p:confirm header="Confirmação" message="Deseja excluir o Fabricante?"
  44. icon="ui-icon-alert">
  45. <f:attribute name="fabricanteSelecionado" value="#{fabricante}" />
  46. </p:confirm>
Add Comment
Please, Sign In to add comment