예제 #1
0
 public void add(Asking asking) {
   Session session = HibernateUtil.getSessionFactory().openSession();
   Transaction tr = session.beginTransaction();
   session.save(asking);
   tr.commit();
   session.close();
 }
예제 #2
0
 public void update(Asking asking) {
   Session session = HibernateUtil.getSessionFactory().openSession();
   Transaction tr = session.beginTransaction();
   if (null != asking) {
     session.update(asking);
   }
   tr.commit();
   session.close();
 }
예제 #3
0
  @Override
  public Asking get(Integer id) {
    Asking result = new Asking();
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction tr = session.beginTransaction();

    result = (Asking) session.get(Asking.class, id);

    tr.commit();
    session.close();
    return result;
  }
예제 #4
0
  @Override
  public List<Asking> getByReplyUser(User user) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction tr = session.beginTransaction();

    Criteria cr = session.createCriteria(Asking.class);
    cr.add(eq("replyUser", user));
    List<Asking> result = (List<Asking>) cr.list();

    tr.commit();
    session.close();
    return result;
  }