Esempio n. 1
0
 @Override
 public void delete(Question entity) {
   session = HibernateUtil.getSessionFactory().getCurrentSession();
   Transaction tx = session.beginTransaction();
   session.delete(entity);
   tx.commit();
 }
Esempio n. 2
0
 @Override
 public List<Question> executeQuery(String query) {
   session = HibernateUtil.getSessionFactory().getCurrentSession();
   Transaction tx = session.beginTransaction();
   List<Question> list = session.createQuery(query).list();
   tx.commit();
   return list;
 }
Esempio n. 3
0
 @Override
 public Integer save(Question entity) {
   session = HibernateUtil.getSessionFactory().getCurrentSession();
   Transaction tx = session.beginTransaction();
   Integer id = (Integer) session.save(entity);
   tx.commit();
   return id;
 }
Esempio n. 4
0
 @Override
 public Question getById(Integer id) {
   session = HibernateUtil.getSessionFactory().getCurrentSession();
   Transaction tx = session.beginTransaction();
   Question entity = (Question) session.get(Question.class, id);
   tx.commit();
   return entity;
 }
Esempio n. 5
0
 @Override
 public List<Question> findAll() {
   session = HibernateUtil.getSessionFactory().getCurrentSession();
   Transaction tx = session.beginTransaction();
   List<Question> list =
       session
           .createSQLQuery("select {question.*} from question")
           .addEntity("question", Question.class)
           .list();
   tx.commit();
   return list;
 }