List of usage examples for org.hibernate Criteria list
public List list() throws HibernateException;
From source file:propfeedbacklist_serv.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./*w w w .j a v a 2s. co m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { SessionFactory sf = NewHibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Transaction tr = ss.beginTransaction(); Criteria cr = ss.createCriteria(PropFeedback.class); ArrayList<PropFeedback> pfl = (ArrayList<PropFeedback>) cr.list(); if (!pfl.isEmpty()) { request.setAttribute("pfl", pfl); RequestDispatcher rd = request.getRequestDispatcher("propfeedbacklist.jsp"); rd.forward(request, response); } } catch (HibernateException e) { out.print(e.getMessage()); } }
From source file:getdoctor.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// ww w .j a v a2s . c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { SessionFactory sf = HibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Transaction tr = ss.beginTransaction(); String code = ""; Criteria cr = ss.createCriteria(Doctor.class); ArrayList<Doctor> all = (ArrayList<Doctor>) cr.list(); Criteria cr1 = ss.createCriteria(Doctor.class); cr1.add(Restrictions.eq("status", "ACTIVE")); if (request.getParameter("sort") != null) { String so = request.getParameter("sort"); if (so.equals("1")) { cr1.addOrder(Order.asc("dFirstname")); } else if (so.equals("2")) { cr1.addOrder(Order.desc("dFirstname")); } //.add( Restrictions.like("name", "F%") //.addOrder( Order.asc("name") ) //.addOrder( Order.desc("age") ) //.setMaxResults(50) // cr.add(Restrictions.eq("password", request.getParameter("password"))); } if (request.getParameter("search") != null) { String so = request.getParameter("search"); cr1.add(Restrictions.like("dFirstname", so + "%")); } ArrayList<Doctor> all1 = (ArrayList<Doctor>) cr1.list(); if (all1.size() > 0) { for (int i = 0; i < all1.size(); i++) { Doctor dd = all1.get(i); out.println("<li class=\"author-comments\" style=\"margin-top: 36px\">\n" + " <div class=\"media\">\n" + " <div class=\"media-left\"> \n" + " <img alt=\"img\" src=\"images/doctor-2.jpg\" class=\"media-object news-img\"> \n" + " </div>\n" + " <div class=\"media-body\">\n" + " <h4 class=\"author-name\">Dr. " + dd.getDFirstname() + " " + dd.getDLastname() + "</h4>\n" + " <span class=\"comments-date\"> " + dd.getQualificationId().getQualificationName() + "</span>\n" + " <p>" + dd.getAddressid().getCityId().getCityName().toString() + "</p>\n" + " <p class=\"fa fa-check-circle\" style=\"color: green\">" + dd.getStatus() + "</p>\n" + " <div class=\"ui heart rating\" data-rating=\"1\" data-max-rating=\"3\"></div>\n" + " <a class=\"reply-btn\" href=\"take_doc_app?docid=" + dd.getDId() + "\">Take Appointment</a>\n" + " </div>\n" + " </div>\n" + " </li>"); } } // request.setAttribute("dlist", all); } catch (HibernateException he) { he.getMessage(); } finally { out.close(); } }
From source file:proplist_serv.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// ww w. j av a 2 s. co m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { SessionFactory sf = NewHibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Transaction tr = ss.beginTransaction(); Criteria cr = ss.createCriteria(PropDetail.class); ArrayList<PropDetail> pdl = (ArrayList<PropDetail>) cr.list(); if (!pdl.isEmpty()) { request.setAttribute("pdl", pdl); } RequestDispatcher rd = request.getRequestDispatcher("proplist.jsp"); rd.forward(request, response); } catch (HibernateException e) { out.print(e.getMessage()); } }
From source file:patient_view_labappointment.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.// w ww . j a va 2s .c o m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { /* TODO output your page here. You may use following sample code. */ SessionFactory sf = HibernateUtil.getSessionFactory(); Session ss = sf.getCurrentSession(); Transaction tr = ss.beginTransaction(); HttpSession hs = request.getSession(); if (hs.getAttribute("patient") != null) { Patient p1 = (Patient) hs.getAttribute("patient"); Criteria cr = ss.createCriteria(LabAppointment.class); cr.add(Restrictions.eq("pId", p1)); ArrayList<LabAppointment> la = (ArrayList<LabAppointment>) cr.list(); if (la.size() > 0) { ArrayList<ArrayList<PatienttestDetail>> testarray = new ArrayList<ArrayList<PatienttestDetail>>( la.size()); for (int i = 0; i < la.size(); i++) { LabAppointment la1 = la.get(i); Criteria cr1 = ss.createCriteria(PatienttestDetail.class); cr1.add(Restrictions.eq("laId", la1)); ArrayList<PatienttestDetail> tests = (ArrayList<PatienttestDetail>) cr1.list(); testarray.add(tests); } request.setAttribute("la", la); if (testarray.size() > 0) { request.setAttribute("ptest", testarray); } System.out.println(testarray); } RequestDispatcher rd = request.getRequestDispatcher("patient_view_labappointment.jsp"); rd.forward(request, response); } else { tr.commit(); RequestDispatcher rd = request.getRequestDispatcher("login.jsp"); rd.forward(request, response); } } }
From source file:admin_add_lab.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from ww w . ja v a 2 s .co m * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { SessionFactory sf = HibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Transaction tr = ss.beginTransaction(); HttpSession hs = request.getSession(); if (hs.getAttribute("admin") != null) { Admin a = (Admin) hs.getAttribute("admin"); if (request.getParameter("status") != null && request.getParameter("lId") != null) { int apid = Integer.parseInt(request.getParameter("lId")); Lab lab1 = (Lab) ss.get(Lab.class, apid); if (request.getParameter("status").equals("approve")) { lab1.setStatus("ACTIVE"); ss.update(lab1); String subject = "Your Appointment is Approved.!"; String content = "Hi," + lab1.getLabName() + " " + "\n" + "Your Request has been approved by Admin" + ".\n"; String mail = lab1.getWebsite(); String[] recipients = new String[] { mail }; //String[] bccRecipients = new String[]{"sunilkotadiya777@gmail.com"}; if (new MailUtil().sendMail(recipients, subject, content)) { } request.setAttribute("msg", "Appointment accepted..!"); } else if (request.getParameter("status").equals("reject")) { lab1.setStatus("REJECTED"); ss.update(lab1); String subject = "Your Request is Rejected.!"; String content = "Hi, " + lab1.getLabName() + " " + "Your Request to join Cardiac Countermeasure has been rejected by admin" + ".\n "; String mail = lab1.getWebsite(); String[] recipients = new String[] { mail }; //String[] bccRecipients = new String[]{"sunilkotadiya777@gmail.com"}; if (new MailUtil().sendMail(recipients, subject, content)) { } request.setAttribute("msg", "Appointment rejected..!"); } } Criteria cr = ss.createCriteria(Lab.class); //cr.add(Restrictions.eq("dId", a)); cr.add(Restrictions.eq("status", "not Active")); ArrayList<Lab> da = (ArrayList<Lab>) cr.list(); if (da.size() > 0) { request.setAttribute("da", da); } tr.commit(); RequestDispatcher rd = request.getRequestDispatcher("admin_add_lab.jsp"); rd.forward(request, response); } else { tr.commit(); RequestDispatcher rd = request.getRequestDispatcher("login.jsp"); rd.forward(request, response); } } catch (HibernateException he) { out.println(he.getMessage()); } finally { out.close(); } }
From source file:viewblogs.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* www. j a v a 2s . com*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { SessionFactory sf = HibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Transaction tr = ss.beginTransaction(); HttpSession hs = request.getSession(); // if (hs.getAttribute("patient") != null) // { Blog b1 = new Blog(); Criteria cr = ss.createCriteria(Blog.class); ArrayList<Blog> da = (ArrayList<Blog>) cr.list(); if (da.size() > 0) { request.setAttribute("da", da); } tr.commit(); RequestDispatcher rd = request.getRequestDispatcher("Blogs.jsp"); rd.forward(request, response); // } // else // { // RequestDispatcher rd = request.getRequestDispatcher("login.jsp"); // rd.forward(request, response); // } } catch (HibernateException he) { out.println(he.getMessage()); } finally { out.close(); } }
From source file:patient_view_docappointment.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* www . j a v a2 s . c o m*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { SessionFactory sf = HibernateUtil.getSessionFactory(); Session ss = sf.getCurrentSession(); Transaction tr = ss.beginTransaction(); HttpSession hs = request.getSession(); if (hs.getAttribute("patient") != null) { Patient p1 = (Patient) hs.getAttribute("patient"); Criteria cr = ss.createCriteria(DoctorAppointment.class); cr.add(Restrictions.eq("pId", p1)); ArrayList<DoctorAppointment> la = (ArrayList<DoctorAppointment>) cr.list(); if (la.size() > 0) { ArrayList<DoctorAppointment> docarray = new ArrayList<DoctorAppointment>(la.size()); // for (int i = 0; i < la.size(); i++) { // DoctorAppointment da1 = la.get(i); // Criteria cr1 = ss.createCriteria(DoctorAppointment.class); // cr1.add(Restrictions.eq("daId", da1)); // ArrayList<DoctorAppointment> tests = (ArrayList<DoctorAppointment>) cr1.list(); // docarray.add(tests); // } Criteria cr1 = ss.createCriteria(DoctorAppointment.class); cr1.add(Restrictions.eq("pId", la)); request.setAttribute("la", la); if (docarray.size() > 0) { request.setAttribute("ptest", docarray); } System.out.println(docarray); } RequestDispatcher rd = request.getRequestDispatcher("patient_view_doctorappointment.jsp"); rd.forward(request, response); } else { tr.commit(); RequestDispatcher rd = request.getRequestDispatcher("login.jsp"); rd.forward(request, response); } } catch (HibernateException he) { he.getMessage(); } finally { out.close(); } }
From source file:GetGroupChatServ.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//w w w. ja v a 2 s . com * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try { SessionFactory sf = NewHibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Transaction tr = ss.beginTransaction(); int gid = Integer.parseInt(request.getParameter("gid")); GroupDetail gd = (GroupDetail) ss.get(GroupDetail.class, gid); System.out.println("Group id is :" + gd.getGId()); Criteria cr = ss.createCriteria(ChatMsg.class); cr.add(Restrictions.eq("gId", gd)); cr.addOrder(Order.desc("cmid")); cr.setMaxResults(25); ArrayList<ChatMsg> cm = (ArrayList<ChatMsg>) cr.list(); Collections.reverse(cm); System.out.println("size of the msg array :" + cm.size()); request.setAttribute("msgs", cm); request.setAttribute("gobj", gd); RequestDispatcher rd = request.getRequestDispatcher("groupchat.jsp"); rd.forward(request, response); } catch (HibernateException he) { System.out.print(he.getMessage()); } }
From source file:BuscarClientePorNome.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods./* w w w.jav a 2 s . c om*/ * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); try (PrintWriter out = response.getWriter()) { /* TODO output your page here. You may use following sample code. */ out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>Servlet BuscarClientePorNome</title>"); out.println("</head>"); out.println("<body>"); Session sessao = HibernateUtil.getSessionFactory().openSession(); Criteria criteria = sessao.createCriteria(Cliente.class); criteria.add(Restrictions.eq("nome", request.getParameter("nome"))); List<Cliente> resultado = criteria.list(); out.println("Cliente encontrado: "); for (Cliente c : resultado) { out.println("<br/>Nome: " + c.getNome()); out.println("<br/>Cpf: " + c.getCpf()); out.println("<br/>Endereco: " + c.getEndereco()); out.println("<br/>"); } out.println("</body>"); out.println("</html>"); } }
From source file:ShowProductServ.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); try {/*from ww w .j av a 2s .c om*/ SessionFactory sf = HibernateUtil.getSessionFactory(); Session ss = sf.openSession(); Criteria cr = ss.createCriteria(ProductTable.class); ArrayList<ProductTable> pList = (ArrayList<ProductTable>) cr.list(); request.setAttribute("pList", pList); RequestDispatcher rd = request.getRequestDispatcher("ProductList.jsp"); rd.forward(request, response); } catch (HibernateException e) { out.println(e.getMessage()); } }