@Override
 public void delete(Question entity) {
   session = HibernateUtil.getSessionFactory().getCurrentSession();
   Transaction tx = session.beginTransaction();
   session.delete(entity);
   tx.commit();
 }
 @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;
 }
 @Override
 public Integer save(Question entity) {
   session = HibernateUtil.getSessionFactory().getCurrentSession();
   Transaction tx = session.beginTransaction();
   Integer id = (Integer) session.save(entity);
   tx.commit();
   return id;
 }
 @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;
 }
 @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;
 }