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.QuestionnaireDAO.java

public void DeleteV(int id) {
    Session session;/*from w  w  w .  j ava 2 s.co  m*/
    SessionFactory sessionfactory = new org.hibernate.cfg.Configuration().configure().buildSessionFactory();
    session = sessionfactory.openSession();
    session.beginTransaction();
    String hgl = "delete from Answerspojo where assessID = :id";
    org.hibernate.Query query = session.createQuery(hgl);
    query.setParameter("id", id);
    query.executeUpdate();
}

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

public void updateforceQ(questionspojo a) {
    Session session = null;/*from w ww  .  j  a  v  a  2 s .  co m*/
    SessionFactory sessionFactory = new org.hibernate.cfg.Configuration().configure().buildSessionFactory();
    session = sessionFactory.openSession();
    session.beginTransaction();

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

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

public void DeleteQ(int id) {
    Session session;//  w w w  . ja  va2  s  .  c  o  m
    SessionFactory sessionfactory = new org.hibernate.cfg.Configuration().configure().buildSessionFactory();
    session = sessionfactory.openSession();
    session.beginTransaction();
    String hgl = "delete from questionspojo where assessID = :id";
    org.hibernate.Query query = session.createQuery(hgl);
    query.setParameter("id", id);
    query.executeUpdate();
}

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

public void updateforce(sme l) {
    Session session = null;//from  w  w w. jav  a 2s  .  c  o 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.smeDAO.java

public void deleteforce(sme l) {
    Session session = null;//from  w ww  . jav a2 s .co m
    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.smeDAO.java

public String checklogin(String email, String password) {
    String e = "", p = "", msg = "";
    Session ses = null;/*from   w w  w  .ja va2s. co  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 2s .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 void updateforce(trainerpojo l) {
    Session session = null;/*from  w w  w. jav a2s . 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.trainerDao.java

public void deleteforce(trainerpojo l) {
    Session session = null;// ww w .  j a v  a2s. 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.trainerDao.java

public List<trainerpojo> findlocandgro(String email) {
    List<trainerpojo> list = new ArrayList<>();
    Session ses = null;//ww w. j  a  va 2  s .  co  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;
}