Example usage for org.hibernate Session clear

List of usage examples for org.hibernate Session clear

Introduction

In this page you can find the example usage for org.hibernate Session clear.

Prototype

void clear();

Source Link

Document

Completely clear the session.

Usage

From source file:com.elearing.impl.McqQuesDaoImpl.java

public List<McqQues> getMCQListOnChapter(ChapterType ch, QuesLevel level, int a) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();//from  www.  j av  a 2 s. co m

    List<McqQues> list = null;

    //   Query qr = session.createQuery("from McqQues where chapterType =:chap and quesLevel =:lev"); 
    Query qr = session.createQuery("from McqQues");

    session.clear();
    session.close();
    Collections.shuffle(list);
    return list.subList(0, a);
}

From source file:com.elearing.impl.QuesLevelDaoImpl.java

@Override
public boolean insert(QuesLevel obj) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();/*from   w  w  w  .j av  a  2s  .c  o m*/
    session.save(obj);
    session.getTransaction().commit();
    session.clear();
    session.close();
    return true;
}

From source file:com.elearing.impl.SubChapterDaoImpl.java

@Override
public boolean insert(SubChapter obj) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();/*  w ww.j a v a2s .  c o m*/
    session.save(obj);
    session.getTransaction().commit();
    session.clear();
    session.close();
    return true;
}

From source file:com.elearing.impl.SubChapterDaoImpl.java

@Override
public boolean update(SubChapter obj) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();//from  w  w  w.j a v  a 2 s.  co  m
    session.update(obj);
    session.getTransaction().commit();
    session.clear();
    session.close();
    return true;
}

From source file:com.elearing.impl.SubChapterDaoImpl.java

@Override
public boolean delete(SubChapter obj) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();/* w ww. j ava 2 s . c o m*/
    session.delete(obj);
    session.getTransaction().commit();
    session.clear();
    session.close();
    return true;
}

From source file:com.elearing.impl.SubChapterDaoImpl.java

@Override
public SubChapter getObjectById(int id) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();//from   w  ww  .  ja v a  2s  .co m
    SubChapter subCh = (SubChapter) session.get(SubChapter.class, id);
    session.clear();
    session.close();
    return subCh; //To change body of generated methods, choose Tools | Templates.
}

From source file:com.elearing.impl.SubChapterDaoImpl.java

public List<SubChapter> chapter(Subject ci) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();/*from  w  ww  . j  a v a 2 s .c om*/
    Query qr = session.createQuery("from SubChapter where subject = :ci");
    qr.setParameter("ci", ci);
    List<SubChapter> list = qr.list();
    session.clear();
    session.close();
    return list;
}

From source file:com.elearing.impl.SubjectDaoImpl.java

@Override
public boolean insert(Subject obj) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();// w  ww  . j a  va 2s  .c o m
    session.save(obj);
    session.getTransaction().commit();
    session.clear();
    session.close();
    return true;
}

From source file:com.elearing.impl.SubjectDaoImpl.java

@Override
public boolean update(Subject obj) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();/*w w  w . j  ava2 s  .c  o  m*/
    session.update(obj);
    session.getTransaction().commit();
    session.clear();
    session.close();
    return true;
}

From source file:com.elearing.impl.SubjectDaoImpl.java

@Override
public boolean delete(Subject obj) {

    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();//from  w w  w .j a  v a 2 s.c  o  m
    session.delete(obj);
    session.getTransaction().commit();
    session.clear();
    session.close();
    return true;

}