List of usage examples for org.hibernate Session update
void update(Object object);
From source file:com.bacic5i5j.framework.database.HibernateAccess.java
License:Open Source License
@Override public void update(T entity) { Session session = sessionFactory.currentSession(); session.update(entity); session.flush();// w ww . ja v a 2 s.c om sessionFactory.closeSession(); }
From source file:com.bakeryfactory.cadastros.servidor.AlmoxarifadoDetalheAction.java
License:Open Source License
private Response update(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request, HttpServletResponse response, HttpSession userSession, ServletContext context) { Session session = null; try {/* ww w. jav a 2 s . c o m*/ Object[] pars = (Object[]) inputPar; AlmoxarifadoVO almoxarifado = (AlmoxarifadoVO) pars[2]; session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.update(almoxarifado); session.getTransaction().commit(); return new VOResponse(almoxarifado); } catch (Exception ex) { if (session != null) { session.getTransaction().rollback(); } ex.printStackTrace(); return new ErrorResponse(ex.getMessage()); } finally { try { if (session != null) { session.close(); } } catch (Exception ex1) { ex1.printStackTrace(); } } }
From source file:com.bakeryfactory.cadastros.servidor.AtividadeForClilDetalheAction.java
License:Open Source License
private Response update(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request, HttpServletResponse response, HttpSession userSession, ServletContext context) { Session session = null; try {/*from ww w. j a va2 s .c o m*/ Object[] pars = (Object[]) inputPar; AtividadeForCliVO atividadeForCli = (AtividadeForCliVO) pars[2]; session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.update(atividadeForCli); session.getTransaction().commit(); return new VOResponse(atividadeForCli); } catch (Exception ex) { ex.printStackTrace(); if (session != null) { session.getTransaction().rollback(); } return new ErrorResponse(ex.getMessage()); } finally { try { if (session != null) { session.close(); } } catch (Exception ex1) { ex1.printStackTrace(); } } }
From source file:com.bakeryfactory.cadastros.servidor.CargoDetalheAction.java
License:Open Source License
private Response update(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request, HttpServletResponse response, HttpSession userSession, ServletContext context) { Session session = null; try {/*from w w w . ja va 2s. com*/ Object[] pars = (Object[]) inputPar; CargoVO cargo = (CargoVO) pars[2]; session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); Criteria criteria = session.createCriteria(ClienteVO.class); criteria.add(Restrictions.eq("empresa", cargo.getEmpresa())); criteria.add(Restrictions.ne("id", cargo.getId())); session.update(cargo); session.getTransaction().commit(); return new VOResponse(cargo); } catch (Exception ex) { ex.printStackTrace(); if (session != null) { session.getTransaction().rollback(); } return new ErrorResponse(ex.getMessage()); } finally { try { if (session != null) { session.close(); } } catch (Exception ex1) { ex1.printStackTrace(); } } }
From source file:com.bakeryfactory.cadastros.servidor.CepDetalheAction.java
License:Open Source License
private Response update(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request, HttpServletResponse response, HttpSession userSession, ServletContext context) { Session session = null; try {/*from w ww . j ava 2 s .c o m*/ Object[] pars = (Object[]) inputPar; CepVO cep = (CepVO) pars[2]; session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.update(cep); session.getTransaction().commit(); return new VOResponse(cep); } catch (Exception ex) { ex.printStackTrace(); if (session != null) { session.getTransaction().rollback(); } return new ErrorResponse(ex.getMessage()); } finally { try { if (session != null) { session.close(); } } catch (Exception ex1) { ex1.printStackTrace(); } } }
From source file:com.bakeryfactory.cadastros.servidor.ClienteDetalheAction.java
License:Open Source License
private Response update(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request, HttpServletResponse response, HttpSession userSession, ServletContext context) { Session session = null; try {//from w ww. j av a2 s . co m Object[] pars = (Object[]) inputPar; ClienteVO cliente = (ClienteVO) pars[2]; session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); Criteria criteria = session.createCriteria(ClienteVO.class); criteria.add(Restrictions.eq("pessoa", cliente.getPessoa())); criteria.add(Restrictions.ne("id", cliente.getId())); if (criteria.uniqueResult() != null) { throw new Exception("J existe um Cliente vinculado pessoa selecionada."); } if (cliente.getContabilConta().getId() == null) { cliente.setContabilConta(null); } if (cliente.getTributOperacaoFiscal().getId() == null) { cliente.setTributOperacaoFiscal(null); } session.update(cliente); session.getTransaction().commit(); return new VOResponse(cliente); } catch (Exception ex) { if (session != null) { session.getTransaction().rollback(); } ex.printStackTrace(); return new ErrorResponse(ex.getMessage()); } finally { try { if (session != null) { session.close(); } } catch (Exception ex1) { ex1.printStackTrace(); } } }
From source file:com.bakeryfactory.cadastros.servidor.ColaboradorDetalheAction.java
License:Open Source License
private Response update(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request, HttpServletResponse response, HttpSession userSession, ServletContext context) { Session session = null; try {/*from ww w . j a v a 2 s . c o m*/ Object[] pars = (Object[]) inputPar; ColaboradorVO colaborador = (ColaboradorVO) pars[2]; session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); Criteria criteria = session.createCriteria(ColaboradorVO.class); criteria.add(Restrictions.eq("pessoa", colaborador.getPessoa())); criteria.add(Restrictions.ne("id", colaborador.getId())); if (criteria.uniqueResult() != null) { throw new Exception("J existe um Colaborador vinculado pessoa selecionada."); } if (colaborador.getContabilConta().getId() == null) { colaborador.setContabilConta(null); } if (colaborador.getSindicato().getId() == null) { colaborador.setSindicato(null); } if (colaborador.getTipoAdmissao().getId() == null) { colaborador.setTipoAdmissao(null); } session.update(colaborador); session.getTransaction().commit(); return new VOResponse(colaborador); } catch (Exception ex) { if (session != null) { session.getTransaction().rollback(); } ex.printStackTrace(); return new ErrorResponse(ex.getMessage()); } finally { try { if (session != null) { session.close(); } } catch (Exception ex1) { ex1.printStackTrace(); } } }
From source file:com.bakeryfactory.cadastros.servidor.EstadoCivilDetalheAction.java
License:Open Source License
private Response update(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request, HttpServletResponse response, HttpSession userSession, ServletContext context) { Session session = null; try {/*ww w .ja v a2s .c o m*/ Object[] pars = (Object[]) inputPar; EstadoCivilVO estadoCivil = (EstadoCivilVO) pars[2]; session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.update(estadoCivil); session.getTransaction().commit(); return new VOResponse(estadoCivil); } catch (Exception ex) { ex.printStackTrace(); if (session != null) { session.getTransaction().rollback(); } return new ErrorResponse(ex.getMessage()); } finally { try { if (session != null) { session.close(); } } catch (Exception ex1) { ex1.printStackTrace(); } } }
From source file:com.bakeryfactory.cadastros.servidor.FornecedorDetalheAction.java
License:Open Source License
private Response update(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request, HttpServletResponse response, HttpSession userSession, ServletContext context) { Session session = null; try {//from www. j av a2 s. c om Object[] pars = (Object[]) inputPar; FornecedorVO fornecedor = (FornecedorVO) pars[2]; Criteria criteria = session.createCriteria(FornecedorVO.class); criteria.add(Restrictions.eq("pessoa", fornecedor.getPessoa())); criteria.add(Restrictions.ne("id", fornecedor.getId())); if (criteria.uniqueResult() != null) { throw new Exception("J Existe um Fornecedor Vinculado Pessoa Selecionada!"); } if (fornecedor.getContabilConta().getId() == null) { fornecedor.setContabilConta(null); } session.update(fornecedor); session.getTransaction().commit(); return new VOResponse(fornecedor); } catch (Exception ex) { ex.printStackTrace(); if (session != null) { session.getTransaction().rollback(); } return new ErrorResponse(ex.getMessage()); } finally { try { if (session != null) { session.close(); } } catch (Exception ex1) { ex1.printStackTrace(); } } }
From source file:com.bakeryfactory.cadastros.servidor.IngredienteDetalheAction.java
License:Open Source License
private Response update(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request, HttpServletResponse response, HttpSession userSession, ServletContext context) { Session session = null; try {// w ww. j a v a 2 s. co m Object[] pars = (Object[]) inputPar; IngredienteVO ingrediente = (IngredienteVO) pars[2]; session.update(ingrediente); session.getTransaction().commit(); return new VOResponse(ingrediente); } catch (Exception ex) { ex.printStackTrace(); if (session != null) { session.getTransaction().rollback(); } return new ErrorResponse(ex.getMessage()); } finally { try { if (session != null) { session.close(); } } catch (Exception ex1) { ex1.printStackTrace(); } } }