示例#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;
  }