List of usage examples for org.hibernate Session load
void load(Object object, Serializable id);
From source file:com.certus.actions.removeDiscountAction.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Session s = com.certus.connection.HibernateUtil.getSessionFactory().openSession(); Product p = (Product) s.load(Product.class, Integer.parseInt(request.getParameter("pid"))); s.beginTransaction();// ww w. j a v a2 s . c o m p.setDiscountPrice(0); s.getTransaction().commit(); s.close(); response.getWriter().write("removed"); }
From source file:com.certus.actions.removeFromWishListAction.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Session s = com.certus.connection.HibernateUtil.getSessionFactory().openSession(); WishList wish = (WishList) s.load(WishList.class, Integer.parseInt(request.getParameter("wid"))); s.beginTransaction();/* w w w. j a va 2 s. c om*/ s.delete(wish); s.getTransaction().commit(); s.close(); response.getWriter().write("Removed Successfully !"); }
From source file:com.certus.actions.restPasswordAdminAction.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String newPass = request.getParameter("confirmNew"); String userId = request.getParameter("uid"); Session s = com.certus.connection.HibernateUtil.getSessionFactory().openSession(); BasicPasswordEncryptor encryptor = new BasicPasswordEncryptor(); if (newPass != null && userId != null && !newPass.isEmpty() && !userId.isEmpty()) { List<Administor> adminList = s.createCriteria(Administor.class).list(); for (Administor admin : adminList) { System.out.println("User id - " + userId); if (encryptor.checkPassword(String.valueOf(admin.getId()), userId)) { userId = String.valueOf(admin.getId()); System.out.println("work here.."); }/* w w w .j a v a 2 s . c o m*/ } Administor adminFound = (Administor) s.load(Administor.class, Integer.parseInt(userId)); if (adminFound != null) { s.beginTransaction(); adminFound.setPassword(encryptor.encryptPassword(newPass)); s.update(adminFound); s.getTransaction().commit(); setAdminNotification(s); s.close(); response.getWriter().write("success"); } else { System.out.println("Coudn't find the acount."); } } }
From source file:com.certus.actions.saveGeneralInfoAction.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Session s = com.certus.connection.HibernateUtil.getSessionFactory().openSession(); SiteGeneral general = (SiteGeneral) s.load(SiteGeneral.class, 1); String addrsG = request.getParameter("addrsG"); String telG = request.getParameter("telG"); String mailG = request.getParameter("mailG"); String footerG = request.getParameter("footerG"); String mainG = request.getParameter("mainG"); String usrDescG = request.getParameter("usrDescG"); if (!addrsG.isEmpty() && !telG.isEmpty() && !mailG.isEmpty() && !footerG.isEmpty() && !mainG.isEmpty() && !usrDescG.isEmpty()) { s.beginTransaction();// w ww. j a va 2s . c om s.update(general); general.setAboutUsFooter(footerG); general.setAboutUsMain(mainG); general.setSiteAddress(addrsG); general.setUsrAcntDesc(usrDescG); general.setTel(telG); general.setSiteMail(mailG); s.getTransaction().commit(); s.close(); response.getWriter().write("You have successfully saved the chanages."); } }
From source file:com.certus.actions.saveImageSettingsAction.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Session s = com.certus.connection.HibernateUtil.getSessionFactory().openSession(); String emailAdd = request.getParameter("emailAdd"); String hostN = request.getParameter("hostN"); String portN = request.getParameter("portN"); String psswrdN = request.getParameter("psswrdN"); if (!emailAdd.isEmpty() && !hostN.isEmpty() && !portN.isEmpty() && !psswrdN.isEmpty()) { EmailSettings es = (EmailSettings) s.load(EmailSettings.class, 1); s.beginTransaction();//from w ww.ja v a 2s . c o m es.setHost(hostN); es.setPassword(psswrdN); es.setUser(emailAdd); es.setPort(Integer.parseInt(portN)); s.update(es); s.getTransaction().commit(); s.close(); response.getWriter().write("You have successfully saved the changes."); } }
From source file:com.certus.actions.savePromotion.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String promoDes = request.getParameter("promoDes"); String promoEnd = request.getParameter("promoEnd"); int promoPlace = Integer.parseInt(request.getParameter("promoPlace")); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); int pid = Integer.parseInt(request.getParameter("pid")); int sid = Integer.parseInt(request.getParameter("sid")); Date parsed = null;/*from w ww.j av a 2 s . c om*/ try { parsed = format.parse(promoEnd); } catch (ParseException ex) { Logger.getLogger(savePromotion.class.getName()).log(Level.SEVERE, null, ex); } Session s = com.certus.connection.HibernateUtil.getSessionFactory().openSession(); Product pro = (Product) s.load(Product.class, pid); Promotions promo = (Promotions) s.load(Promotions.class, promoPlace); s.beginTransaction(); promo.setDateEnded(new java.sql.Date(parsed.getTime())); promo.setDescription(promoDes); promo.setProId(pro); s.update(promo); s.getTransaction().commit(); s.close(); response.sendRedirect("edit_product.jsp?pid=" + pid + "&sid=" + sid); }
From source file:com.certus.actions.saveSilteTermsAndConditionsAction.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String mainSec = request.getParameter("mainSec"); String securedSec = request.getParameter("securedSec"); String serviceOff = request.getParameter("serviceOff"); String privcyPol = request.getParameter("privcyPol"); String condRuls = request.getParameter("condRuls"); String comPolyT = request.getParameter("comPolyT"); String extNotGurntT = request.getParameter("extNotGurntT"); String limitationT = request.getParameter("limitationT"); String pricingT = request.getParameter("pricingT"); String serviceFeesT = request.getParameter("serviceFeesT"); String delivryT = request.getParameter("delivryT"); System.out.println("work here"); Session s = com.certus.connection.HibernateUtil.getSessionFactory().openSession(); TermsConditions conditions = (TermsConditions) s.load(TermsConditions.class, 1); if (!mainSec.isEmpty() && !securedSec.isEmpty() && !serviceOff.isEmpty() && !privcyPol.isEmpty() && !condRuls.isEmpty() && !comPolyT.isEmpty() && !extNotGurntT.isEmpty() && !extNotGurntT.isEmpty() && !limitationT.isEmpty() && !pricingT.isEmpty() && !serviceFeesT.isEmpty() && !delivryT.isEmpty()) { System.out.println("work here too"); s.beginTransaction();//from w ww . java 2 s . com conditions.setMainSec(mainSec); conditions.setSecuritySec(securedSec); conditions.setServiceFees(serviceFeesT); conditions.setServiceOffered(serviceOff); conditions.setPrivacyPolicy(privcyPol); conditions.setUsrCnductRules(condRuls); conditions.setCompensationPolicy(comPolyT); conditions.setExtnessGrnteed(extNotGurntT); conditions.setLimitationOfLiability(limitationT); conditions.setPricing(pricingT); conditions.setServiceFees(serviceFeesT); conditions.setDelivery(delivryT); s.update(conditions); s.getTransaction().commit(); s.close(); response.getWriter().write("You have successfully saved the changes."); } }
From source file:com.certus.actions.SendAdminMsgAction.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Session s = com.certus.connection.HibernateUtil.getSessionFactory().openSession(); if (request.getParameter("msg") != null) { Order ordr = (Order) s.load(Order.class, Integer.parseInt(request.getParameter("oid"))); Messages msg = new Messages(); s.beginTransaction();//from w w w . j ava2s. c o m msg.setMessage(request.getParameter("msg")); msg.setOrder(ordr); msg.setAdminSent(true); msg.setAdminViewed(true); msg.setDateSent(new Date(new java.util.Date().getTime())); s.save(msg); s.getTransaction().commit(); s.close(); response.getWriter().write("success."); } }
From source file:com.certus.actions.setAsMainImgAction.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (request.getParameter("imgId") != null) { Session s = com.certus.connection.HibernateUtil.getSessionFactory().openSession(); ProImg img = (ProImg) s.load(ProImg.class, Integer.parseInt(request.getParameter("imgId"))); int proId = img.getProduct().getId(); Product product = (Product) s.load(Product.class, proId); s.beginTransaction();// ww w . j a va2 s . co m product.setImageMain(img.getImage()); s.update(product); s.getTransaction().commit(); s.close(); response.getWriter().write("Updated Successfully !"); } else { response.getWriter().write("Error"); } }
From source file:com.certus.actions.setAsViewedAction.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Session s = com.certus.connection.HibernateUtil.getSessionFactory().openSession(); Messages msg = (Messages) s.load(Messages.class, Integer.parseInt(request.getParameter("mid"))); s.beginTransaction();/*from ww w .j a v a2s . com*/ msg.setAdminViewed(true); s.update(msg); s.getTransaction().commit(); s.close(); response.getWriter().write("success"); }