예제 #1
0
 @Override
 public void delete(Question entity) {
   session = HibernateUtil.getSessionFactory().getCurrentSession();
   Transaction tx = session.beginTransaction();
   session.delete(entity);
   tx.commit();
 }
예제 #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;
 }
예제 #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;
 }
예제 #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;
 }
예제 #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;
 }