public void deletePicture(Integer pictureId) throws Exception {
   Session session = HibernateSessionFactory.getSession();
   Transaction transaction = session.beginTransaction();
   try {
     PictureDAO pictureDao = new PictureDAO();
     List pictures = pictureDao.getPicturesByPictureId(pictureId);
     if (pictures.size() > 0) {
       TPicture picture = (TPicture) pictures.get(0);
       picture.setDeleted(1);
       pictureDao.savePicture(picture);
     }
     transaction.commit();
   } catch (Exception e) {
     transaction.rollback();
     throw e;
   } finally {
     HibernateSessionFactory.closeSession();
   }
 }
 public Integer addPicture(User user, String path) throws Exception {
   Session session = HibernateSessionFactory.getSession();
   Transaction transaction = session.beginTransaction();
   try {
     PictureDAO dao = new PictureDAO();
     TPicture picture = new TPicture();
     picture.setFilenamePath(path);
     picture.setUser(user);
     picture.setMainPagePic(0);
     picture.setDeleted(0);
     picture = dao.savePicture(picture);
     transaction.commit();
     return picture.getPictureId();
   } catch (Exception e) {
     transaction.rollback();
     throw e;
   } finally {
     HibernateSessionFactory.closeSession();
   }
 }