Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- java.lang.IllegalArgumentException: attempt to create delete event with null entity
- at org.hibernate.event.spi.DeleteEvent.<init>(DeleteEvent.java:48)
- at org.hibernate.internal.SessionImpl.delete(SessionImpl.java:896)
- at br.com.drogaria.dao.GenericDAO.excluir(GenericDAO.java:48)
- at br.com.drogaria.bean.FabricanteBean.excluir(FabricanteBean.java:62)
- public void excluir(Entidade entidade) {
- Session sessao = HibernateUtil.getFabricaDeSessoes().openSession();
- Transaction transacao = null;
- try {
- transacao = sessao.beginTransaction();
- sessao.delete(entidade);
- transacao.commit();
- } catch (RuntimeException erro) {
- if (transacao != null) {
- transacao.rollback();
- }
- throw erro;
- } finally {
- sessao.close();
- }
- }
- public void excluir(ActionEvent evento) {
- try {
- this.fabricante = (Fabricante) evento.getComponent().getAttributes().get("fabricanteSelecionado");
- FabricanteDAO fabricanteDAO = new FabricanteDAO();
- //this.fabricante = fabricanteDAO.buscar(fabricante.getCodigo());
- fabricanteDAO.excluir(fabricante);
- this.fabricantes = fabricanteDAO.listar();
- Messages.addGlobalInfo("Fabricante excluído com sucesso!");
- } catch (RuntimeException erro) {
- Messages.addGlobalError("Ocorreu um erro ao tentar excluir um Fabricante.");
- erro.printStackTrace();
- }
- <p:commandButton icon="ui-icon-trash" actionListener="#{fabricanteBean.excluir}"
- update=":mensagem :formListagem:tabela" title="Excluir">
- <p:confirm header="Confirmação" message="Deseja excluir o Fabricante?"
- icon="ui-icon-alert">
- <f:attribute name="fabricanteSelecionado" value="#{fabricante}" />
- </p:confirm>
Add Comment
Please, Sign In to add comment