Example usage for org.hibernate SessionFactory openSession

List of usage examples for org.hibernate SessionFactory openSession

Introduction

In this page you can find the example usage for org.hibernate SessionFactory openSession.

Prototype

Session openSession() throws HibernateException;

Source Link

Document

Open a Session .

Usage

From source file:com.Accenture.DAO.learnerDao.java

public List<learnerspojo> getByEmail(String email) {
    List<learnerspojo> list = new ArrayList<>();
    Session session = null;/*from   ww w  .jav  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 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();
        list.add(l);
    }
    return list;
}

From source file:com.Accenture.DAO.learnerDao.java

public String checklogin(String email, String password) {
    String e = "", p = "", msg = "";
    Session ses = null;// w ww  .  jav  a 2 s. c  om
    SessionFactory sf = new org.hibernate.cfg.Configuration().configure().buildSessionFactory();
    ses = sf.openSession();
    ses.beginTransaction();
    String HQL_QUERY = "from learnerspojo  learners 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();) {
        learnerspojo b = (learnerspojo) 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.learnerDao.java

public List<learnerspojo> search(int id) {
    List<learnerspojo> result = new ArrayList<learnerspojo>();
    Session session = null;//  w ww . ja  va  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 lid=" + id;
    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> search0(String group, String loc) {
    List<learnerspojo> result = new ArrayList<learnerspojo>();
    Session session = null;// w w  w .java  2s  .c  om
    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;/*www .  j  a v  a2s. c  om*/
    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;//from w w  w.  ja v a 2 s  .c o  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 void updateforce(locationpojo l) {
    Session session = null;//from  w  w  w  .j  a  va2s  .co m
    SessionFactory sessionFactory = new org.hibernate.cfg.Configuration().configure().buildSessionFactory();
    session = sessionFactory.openSession();
    session.beginTransaction();

    session.update(l);
    session.getTransaction().commit();
    session.flush();
    session.close();
}

From source file:com.Accenture.DAO.locationDao.java

public void deleteforce(locationpojo l) {
    Session session = null;//w  w w  .  j a va2  s . c  om
    SessionFactory sessionFactory = new org.hibernate.cfg.Configuration().configure().buildSessionFactory();
    session = sessionFactory.openSession();
    session.beginTransaction();

    session.delete(l);
    session.getTransaction().commit();
    session.flush();
    session.close();
}

From source file:com.Accenture.DAO.locationDao.java

public String checklogin(String email, String password) {
    String e = "", p = "", msg = "";
    Session ses = null;// w w  w .j av a  2 s. c  om
    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.QuestionnaireDAO.java

public void updateforceV(Answerspojo a) {
    Session session = null;/*from  ww  w.ja va2 s.  c om*/
    SessionFactory sessionFactory = new org.hibernate.cfg.Configuration().configure().buildSessionFactory();
    session = sessionFactory.openSession();
    session.beginTransaction();

    session.update(a);
    session.getTransaction().commit();
    session.flush();
    session.close();
}