List of usage examples for org.hibernate Query iterate
Iterator<R> iterate();
From source file:com.Accenture.DAO.learnerDao.java
public List<learnerspojo> search0(String group, String loc) { List<learnerspojo> result = new ArrayList<learnerspojo>(); Session session = null;//from w ww . j a v a 2s. c o m SessionFactory sessionfactory = new org.hibernate.cfg.Configuration().configure().buildSessionFactory(); session = sessionfactory.openSession(); session.beginTransaction(); String HQL_QUERY = "from learnerspojo l where groups='" + group + "' AND location='" + loc + "'"; org.hibernate.Query query = session.createQuery(HQL_QUERY); for (Iterator it = query.iterate(); it.hasNext();) { learnerspojo l = (learnerspojo) it.next(); l.getEmail(); l.getGender(); l.getGroups(); l.getId(); l.getLID(); l.getLName(); l.getLSurname(); l.getNumber(); l.getPassword(); l.getRace(); l.getStatus(); l.getTitle(); result.add(l); } return result; }
From source file:com.Accenture.DAO.learnerDao.java
public List<learnerspojo> getlearnerdetails(String email) { List<learnerspojo> result = new ArrayList<learnerspojo>(); Session session = null;/*from w w w . j av a 2s. co m*/ SessionFactory sessionfactory = new org.hibernate.cfg.Configuration().configure().buildSessionFactory(); session = sessionfactory.openSession(); session.beginTransaction(); String HQL_QUERY = "from learnerspojo l where email ='" + email + "'"; org.hibernate.Query query = session.createQuery(HQL_QUERY); for (Iterator it = query.iterate(); it.hasNext();) { learnerspojo l = (learnerspojo) it.next(); l.getEmail(); l.getGender(); l.getGroups(); l.getId(); l.getLID(); l.getLName(); l.getLSurname(); l.getNumber(); l.getPassword(); l.getRace(); l.getStatus(); l.getTitle(); result.add(l); } return result; }
From source file:com.Accenture.DAO.learnerDao.java
public List<LearnerAssessmentPojo> marks(int id) { List<LearnerAssessmentPojo> result = new ArrayList<>(); Session session = null;// w ww . j a v a 2 s . co m SessionFactory sessionfactory = new org.hibernate.cfg.Configuration().configure().buildSessionFactory(); session = sessionfactory.openSession(); session.beginTransaction(); String HQL_QUERY = "from LearnerAssessmentPojo lassessment where learnerID=" + id; org.hibernate.Query query = session.createQuery(HQL_QUERY); for (Iterator it = query.iterate(); it.hasNext();) { LearnerAssessmentPojo l = (LearnerAssessmentPojo) it.next(); l.getAssessmentID(); l.getDateEntered(); l.getID(); l.getLearnerID(); l.getMarks(); result.add(l); } return result; }
From source file:com.Accenture.DAO.locationDao.java
public String checklogin(String email, String password) { String e = "", p = "", msg = ""; Session ses = null;/*from w ww . j a va 2s .c o m*/ SessionFactory sf = new org.hibernate.cfg.Configuration().configure().buildSessionFactory(); ses = sf.openSession(); ses.beginTransaction(); String HQL_QUERY = "from trainerpojo trainer where email =:email and password =:password"; org.hibernate.Query query = ses.createQuery(HQL_QUERY); query.setParameter("email", email); query.setParameter("password", password); for (Iterator it = query.iterate(); it.hasNext();) { trainerpojo b = (trainerpojo) it.next(); e = b.getEmail(); p = b.getPassword(); } if (e.equals(email) && p.equals(password)) { msg = "yes"; } return msg; }
From source file:com.Accenture.DAO.smeDAO.java
public String checklogin(String email, String password) { String e = "", p = "", msg = ""; Session ses = null;/*ww w .j a v a 2 s . c o m*/ SessionFactory sf = new org.hibernate.cfg.Configuration().configure().buildSessionFactory(); ses = sf.openSession(); ses.beginTransaction(); String HQL_QUERY = "from sme sme where companyemail =:email and companypassword =:password"; org.hibernate.Query query = ses.createQuery(HQL_QUERY); query.setParameter("email", email); query.setParameter("password", password); for (Iterator it = query.iterate(); it.hasNext();) { sme b = (sme) it.next(); e = b.getCompanyemail(); p = b.getCompanypassword(); } if (e.equals(email) && p.equals(password)) { msg = "yes"; } return msg; }
From source file:com.Accenture.DAO.smeDAO.java
public List<sme> findlocandgro(String email) { List<sme> list = new ArrayList<>(); Session ses = null;/*from w w w .j a va 2 s . c om*/ SessionFactory sf = new org.hibernate.cfg.Configuration().configure().buildSessionFactory(); ses = sf.openSession(); ses.beginTransaction(); String HQL_QUERY = "from sme sme where companyemail =:email"; org.hibernate.Query query = ses.createQuery(HQL_QUERY); query.setParameter("email", email); for (Iterator it = query.iterate(); it.hasNext();) { sme b = (sme) it.next(); b.getCompanyaddress(); b.getCompanycontact(); b.getCompanyemail(); b.getCompanygroupid(); b.getCompanyname(); b.getCompanypassword(); b.getCompanylocation(); list.add(b); } return list; }
From source file:com.Accenture.DAO.trainerDao.java
public List<trainerpojo> findlocandgro(String email) { List<trainerpojo> list = new ArrayList<>(); Session ses = null;//from w w w . j ava2 s .c o m SessionFactory sf = new org.hibernate.cfg.Configuration().configure().buildSessionFactory(); ses = sf.openSession(); ses.beginTransaction(); String HQL_QUERY = "from trainerpojo trainer where email =:email"; org.hibernate.Query query = ses.createQuery(HQL_QUERY); query.setParameter("email", email); for (Iterator it = query.iterate(); it.hasNext();) { trainerpojo b = (trainerpojo) it.next(); b.getGroup(); b.getLocation(); b.getEmail(); b.getGender(); b.getName(); b.getIdNumber(); b.getSurname(); b.getContact(); list.add(b); } return list; }
From source file:com.Accenture.DAO.trainerDao.java
public List<markregister> findattendance(String email) { List<markregister> list = new ArrayList<>(); Session ses = null;// ww w . j a va2s.c om SessionFactory sf = new org.hibernate.cfg.Configuration().configure().buildSessionFactory(); ses = sf.openSession(); ses.beginTransaction(); String HQL_QUERY = "from markregister markregister where fname =:email"; org.hibernate.Query query = ses.createQuery(HQL_QUERY); query.setParameter("email", email); for (Iterator it = query.iterate(); it.hasNext();) { markregister b = (markregister) it.next(); b.getLname(); b.getStatus(); b.getDate(); list.add(b); } return list; }
From source file:com.Accenture.DAO.trainerDao.java
public List<trainerpojo> search0(String group, String loc) { List<trainerpojo> result = new ArrayList<>(); Session session = null;// w w w .ja va 2 s . c o m SessionFactory sessionfactory = new org.hibernate.cfg.Configuration().configure().buildSessionFactory(); session = sessionfactory.openSession(); session.beginTransaction(); String HQL_QUERY = "from trainerpojo trainerpojo where groupID='" + group + "' AND location='" + loc + "'"; org.hibernate.Query query = session.createQuery(HQL_QUERY); for (Iterator it = query.iterate(); it.hasNext();) { trainerpojo l = (trainerpojo) it.next(); l.getEmail(); l.getContact(); l.getGender(); l.getIdNumber(); l.getLocation(); l.getName(); l.getQualification(); l.getSurname(); result.add(l); } return result; }
From source file:com.Accenture.Java.Viewlearner.java
/** * Handles the HTTP <code>GET</code> method. * * @param request servlet request/*from w w w. jav a2 s .c om*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=UTF-8"); Session session; 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 Viewlearner</title>"); out.println("</head>"); out.println("<body>"); SessionFactory sessionfactory = new org.hibernate.cfg.Configuration().configure().buildSessionFactory(); session = sessionfactory.openSession(); session.beginTransaction(); String hgl = "from grouppojo groups"; org.hibernate.Query query = session.createQuery(hgl); //query.setParameter(hgl, out); System.out.println("Reading values"); for (Iterator it = query.iterate(); it.hasNext();) { grouppojo model = (grouppojo) it.next(); out.println("Reading the location table"); out.println("<h2>" + model.getGroupid() + "</h2>"); out.println("<h2>" + model.getGname() + "</h2>"); out.println("<h2>" + model.getStart() + "</h2>"); out.println("</br>"); } session.getTransaction().commit(); System.out.println("Done!"); out.println("<h1>Servlet Viewlearner at " + request.getContextPath() + "</h1>"); out.println("</body>"); out.println("</html>"); } }