List of usage examples for org.hibernate Session update
void update(Object object);
From source file:com.bakeryfactory.vendas.servidor.VendaRomaneioEntregaDetalheAction.java
License:Open Source License
private Response insert(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request, HttpServletResponse response, HttpSession userSession, ServletContext context) { Session session = null; try {//from ww w.ja v a 2 s . com Object[] pars = (Object[]) inputPar; VendaRomaneioEntregaVO vendaRomaneioEntrega = (VendaRomaneioEntregaVO) pars[1]; List<VendaCabecalhoVO> vendas = (Vector) pars[2]; session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.save(vendaRomaneioEntrega); for (int i = 0; i < vendas.size(); i++) { vendas.get(i).setVendaRomaneioEntrega(vendaRomaneioEntrega); session.update(vendas.get(i)); } session.getTransaction().commit(); return new VOResponse(vendaRomaneioEntrega); } 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.vendas.servidor.VendaRomaneioEntregaDetalheAction.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 w w . j a v a 2s.co m Object[] pars = (Object[]) inputPar; VendaRomaneioEntregaVO vendaRomaneioEntrega = (VendaRomaneioEntregaVO) pars[2]; List<VendaCabecalhoVO> vendas = (Vector) pars[3]; session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.update(vendaRomaneioEntrega); queryExcluir(vendas, vendaRomaneioEntrega, session); session.getTransaction().commit(); return new VOResponse(vendaRomaneioEntrega); } 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.vendas.servidor.VendaRomaneioEntregaDetalheAction.java
License:Open Source License
public void queryExcluir(List<VendaCabecalhoVO> vendas, VendaRomaneioEntregaVO vendaRomaneioEntrega, Session session) throws HibernateException { String sqlExcluir = "update VENDA_CABECALHO set ID_VENDA_ROMANEIO_ENTREGA = null where ID not in (0"; for (int i = 0; i < vendas.size(); i++) { vendas.get(i).setVendaRomaneioEntrega(vendaRomaneioEntrega); session.update(vendas.get(i)); sqlExcluir += "," + vendas.get(i).getId(); }/*from ww w .ja v a 2 s.co m*/ sqlExcluir += ") and ID_VENDA_ROMANEIO_ENTREGA = :id"; Query query = session.createSQLQuery(sqlExcluir); query.setInteger("id", vendaRomaneioEntrega.getId()); query.executeUpdate(); }
From source file:com.balero.models.BlogDAO.java
License:Open Source License
@Transactional public void updatePost(int id, String posttitle, String postbody, String postslug, String postlocale, String postauhtor, String poststatus) { Session session = sessionFactory.openSession(); Blog Blog = new Blog(); Blog.setId(id);//from www . jav a 2 s . co m Blog.setPosttitle(posttitle); Blog.setPostbody(postbody); Blog.setPostslug(postslug); Blog.setPostlocale(postlocale); Blog.setPostauthor(postauhtor); Blog.setPoststatus(poststatus); session.update(Blog); session.flush(); session.close(); }
From source file:com.balero.models.FooterDAO.java
License:Open Source License
@Transactional public void updateFooter(int id, String footercontent) { Session session = sessionFactory.openSession(); Footer footer = new Footer(); footer.setId(id);/*from w w w . ja va2s.com*/ footer.setFootercontent(footercontent); session.update(footer); session.flush(); session.close(); }
From source file:com.balero.models.SettingsDAO.java
License:Open Source License
@Transactional public void save(long id, String sitename, String slogan, String url, String navbar) { Session session = sessionFactory.getCurrentSession(); Settings settings = new Settings(); settings.setId(id);//from w ww.ja v a 2s.co m settings.setSitename(sitename); settings.setSlogan(slogan); settings.setUrl(url); settings.setNavbar(navbar); session.update(settings); session.flush(); }
From source file:com.balero.models.StaticPagesDAO.java
License:Open Source License
@Transactional public void updatePage(int id, String pagename, String pagebody, String pageslug, String pagelocale) { Session session = sessionFactory.openSession(); StaticPages staticPages = new StaticPages(); staticPages.setId(id);//ww w. j a v a2 s.c om staticPages.setPagename(pagename); staticPages.setPagebody(pagebody); staticPages.setPageslug(pageslug); staticPages.setPagelocale(pagelocale); session.update(staticPages); session.flush(); session.close(); }
From source file:com.balero.models.UsersDAO.java
License:Open Source License
@Transactional public void administratorCredentials(String password) { Session session = sessionFactory.getCurrentSession(); Users users = new Users(); users.setId(1); // Admin credentials id = 1 users.setUsername("admin"); users.setPassword(password);//from www . java 2 s.co m users.setAuth("god"); session.update(users); session.flush(); }
From source file:com.britesnow.snow.web.db.hibernate.HibernateDaoHelperImpl.java
License:Apache License
@Transactional public <T> T update(T entity) { Session session = getSession(); try {/*from w w w . ja v a 2s. com*/ session.update(entity); } catch (Throwable e) { throw new SnowHibernateException(e); } return entity; }
From source file:com.bs.dao.AddressDao.java
@Override public boolean doUpdateAddress(Address address) { Session s = HibernateUtil.getSessionFactory().openSession(); try {// www. j a v a 2 s .c o m s.beginTransaction(); s.update(address); s.getTransaction().commit(); return true; } catch (Exception e) { return false; } finally { s.close(); } }