public Leave detail(int id) {
   Session session = HibernateSessionFactory.getSession();
   session.beginTransaction();
   Leave leave = (Leave) session.get(Leave.class, id);
   session.getTransaction().commit();
   HibernateSessionFactory.closeSession();
   return leave;
 }
 public void delete(int id) {
   Session session = HibernateSessionFactory.getSession();
   session.beginTransaction();
   Leave leave = (Leave) session.get(Leave.class, id);
   session.delete(leave);
   session.getTransaction().commit();
   HibernateSessionFactory.closeSession();
 }
Exemple #3
0
 public boolean islike(Integer userid, Integer goodsid) {
   Session session = null;
   Like like = null;
   try {
     session = HibernateSessionFactory.getSession();
     like = new Like(userid, goodsid, null);
     like = (Like) session.get(Like.class, like);
   } catch (Exception e) {
     // TODO: handle exception
     System.err.println(e);
     System.out.println("likeDao.islike()");
     return false;
   } finally {
     session.flush();
     session.clear();
     HibernateSessionFactory.closeSession();
   }
   if (like == null) {
     return false;
   }
   return true;
 }
Exemple #4
0
 /**
  * 取消喜爱作品
  *
  * @param userid
  * @param goodsid
  * @return
  */
 public boolean unlikeGoods(Integer userid, Integer goodsid) {
   Transaction tx = null;
   Session session = null;
   try {
     session = HibernateSessionFactory.getSession();
     tx = session.beginTransaction();
     Like like = new Like(userid, goodsid, null);
     like = (Like) session.get(Like.class, like);
     session.delete(like);
     tx.commit();
   } catch (Exception e) {
     // TODO: handle exception
     System.err.println(e);
     System.out.println("likeDao.unlikeGoods()");
     tx.rollback();
     return false;
   } finally {
     session.flush();
     session.clear();
     HibernateSessionFactory.closeSession();
   }
   return true;
 }
Exemple #5
0
 /**
  * 喜爱作品
  *
  * @param userid
  * @param goodsid
  * @return
  */
 public boolean likeGoods(Integer userid, Integer goodsid) {
   Transaction tx = null;
   Session session = null;
   try {
     session = HibernateSessionFactory.getSession();
     tx = session.beginTransaction();
     System.out.println(userid + "," + goodsid);
     Like like = new Like(userid, goodsid, GLobalMethod.getNowTime());
     session.save(like);
     tx.commit();
   } catch (Exception e) {
     // TODO: handle exception
     System.err.println(e);
     System.out.println("likeDao.likeGoods()");
     tx.rollback();
     return false;
   } finally {
     session.flush();
     session.clear();
     HibernateSessionFactory.closeSession();
   }
   return true;
 }