Package org.hibernate

Examples of org.hibernate.Session$LockRequest


    }
    if (album_id > 0){
      hql.append(" AND p.album.id=:album");
    }
    hql.append(" ORDER BY p.id DESC");
    Session ssn = getSession();
    try{
      Query q = ssn.createQuery(hql.toString());
      q.setInteger("photo_status", PhotoBean.STATUS_NORMAL);
      q.setInteger("site", site.getId());
      q.setInteger("photo", photo_id);
      if(album_id > 0)
        q.setInteger("album", album_id);
View Full Code Here


    }
    if (album_id > 0){
      hql.append(" AND p.album.id=:album");
    }
    hql.append(" ORDER BY p.id ASC");
    Session ssn = getSession();
    try{
      Query q = ssn.createQuery(hql.toString());
      q.setInteger("photo_status", PhotoBean.STATUS_NORMAL);
      q.setInteger("site", site.getId());
      q.setInteger("photo", photo_id);
      if(album_id > 0)
        q.setInteger("album", album_id);
View Full Code Here

    }
    if(date>0){
      hql.append(" AND p.date=:date");
    }
    hql.append(" ORDER BY p.id DESC");
    Session ssn = getSession();
    try{
      Query q = ssn.createQuery(hql.toString());
      q.setInteger("site", site.getId());
      if(album_id > 0)
        q.setInteger("album", album_id);
      if(month_stamp > 190000 && month_stamp < 209912){
        q.setInteger("year", month_stamp / 100);
View Full Code Here

    hql.append(" AND p.status<>:hidden_status AND p.album.type=:owner_album");
    if(date>0){
      hql.append(" AND p.date=:date");
    }
    hql.append(" AND p.site.status=:site_status ORDER BY p.id DESC");
    Session ssn = getSession();
    try{
      Query q = ssn.createQuery(hql.toString());
      if(album_id > 0)
        q.setInteger("album", album_id);
      if(month_stamp > 190000 && month_stamp < 209912){
        q.setInteger("year", month_stamp / 100);
        q.setInteger("month", month_stamp % 100);
View Full Code Here

      hql.append(" AND p.status=:normal_status AND p.album.type=:public_album");
    }
    if(date>0){
      hql.append(" AND p.date=:date");
    }
    Session ssn = getSession();
    try{
      Query q = ssn.createQuery(hql.toString());
      q.setInteger("site", site.getId());
      if(album_id > 0)
        q.setInteger("album", album_id);
      if(month_stamp > 190000 && month_stamp < 209912){
        q.setInteger("year", month_stamp / 100);
View Full Code Here

   * @throws SQLException
   */
  public static void delete(_PhotoBase photo) throws SQLException{
    if(photo == null)
      return;
    Session ssn = getSession();
    try{
      beginTransaction();
      //�ͷ����ռ�
      int photo_size = DLOG4JUtils.sizeInKbytes(photo.getPhotoInfo().getSize());
      photo.getSite().getCapacity().incPhotoUsed(photo_size);
      photo.getAlbum().incPhotoCount(-1);
      photo.getUser().getCount().incPhotoCount(-1);
      //�ݹ����и��ಾ
      AlbumBean parent = photo.getAlbum().getParent();
      int deep = 0;
      do{
        if(parent == null)
          break;
        deep ++;
        parent.incPhotoCount(-1);
        parent = parent.getParent();
      }while(deep < 10);//������ʮ���ಾ

      //ɾ����ǩ
      TagDAO.deleteTagByRefId(photo.getId(), TagBean.TYPE_PHOTO);
     
      //���в������Ƭ�����ߵ������������һ
      List rpls = photo.getReplies();
      for(int i=0;rpls!=null&&i<rpls.size();i++){
        PhotoReplyBean prb = (PhotoReplyBean)rpls.get(i);
        if(prb.getUser()!=null){
          prb.getUser().getCount().incPhotoReplyCount(-1);
        }
      }
     
      //�޸����ø���ƬΪ������ಾ
      executeUpdate("UPDATE AlbumBean AS a SET a.cover = NULL WHERE a.cover.id=?", photo.getId());
     
      ssn.delete(photo);
      commit();
    }catch(HibernateException e){
      rollback();
      throw e;
    }
View Full Code Here

    photo.setYear(cal.get(Calendar.YEAR));
    photo.setMonth((cal.get(Calendar.MONTH)+1));
    photo.setDate(cal.get(Calendar.DATE));
    photo.setCreateTime(cal.getTime());

    Session ssn = getSession();
    try{
      beginTransaction();
      //�޸�site���������ռ�
      int photo_site = DLOG4JUtils.sizeInKbytes(photo.getPhotoInfo().getSize());
      photo.getSite().getCapacity().incPhotoUsed(photo_site);
      //�޸��ಾ����Ƭ��
      album.setPhotoCount(album.getPhotoCount()+1);
      if(cover)
        album.setCover(photo);
      //�ݹ����и��ಾ
      AlbumBean parent = album.getParent();
      int deep = 0;
      do{
        if(parent == null)
          break;
        deep ++;
        parent.incPhotoCount(1);
        parent = parent.getParent();
      }while(deep < 10);//������ʮ���ಾ

      photo.getUser().getCount().incPhotoCount(1);
     
      ssn.save(photo);
     
      if (album.getType() == AlbumBean.TYPE_PUBLIC
          && photo.getStatus() != PhotoBean.STATUS_PRIVATE) {
        List tags = photo.getKeywords();
        if(tags!=null && tags.size()>0){
          int tag_count = 0;
          for(int i=0;i<tags.size();i++){
            if(tag_count>=MAX_TAG_COUNT)
              break;
            String tag_name = (String)tags.get(i);
            if(tag_name.getBytes().length > MAX_TAG_LENGTH)
              continue;
            TagBean tag = new TagBean();
            tag.setSite(photo.getSite());
            tag.setRefId(photo.getId());
            tag.setRefType(DiaryBean.TYPE_PHOTO);
            tag.setName(tag_name);
            ssn.save(tag);
            tag_count ++;
          }
        }
      }
     
View Full Code Here

    if(sid < 1)
      return -1;
    StringBuffer hql = new StringBuffer("SELECT SUM(p.photoInfo.size) FROM PhotoBean AS p WHERE p.site.id=?");
    if(album_id > 0)
      hql.append(" AND p.album.id=?");
    Session ssn = getSession();
    Query q = ssn.createQuery(hql.toString());
    q.setInteger(0, sid);
    if(album_id > 0)
      q.setInteger(1, album_id);
    try{
      Number size = (Number)q.uniqueResult();
View Full Code Here

    if(album_id > 0)
      hql.append(" AND p.album.id=:album");
    if(month >= 190001 && month <= 209912){
      hql.append(" AND p.year = :year AND p.month = :month");
    }
    Session ssn = getSession();
    Query q = ssn.createQuery(hql.toString());
    q.setInteger("site", sid);
    if(album_id > 0)
      q.setInteger("album", album_id);
    if(month >= 190001 && month <= 209912){
      q.setInteger("year", month / 100);
View Full Code Here

      //�ų��û�û��Ȩ�޷��ʵķ���
      hql.append(" AND j.status=:status AND j.album.type=:album_type");
    }
       
    try{
      Session ssn = getSession();
      Query q = ssn.createQuery(hql.toString()).setCacheable(true);
      q.setTimestamp("beginTime", firstDate.getTime());
      q.setTimestamp("endTime", nextMonthFirstDate.getTime());
      q.setInteger("site", site.getId());
      if(!is_owner){
        q.setInteger("status", PhotoBean.STATUS_NORMAL);
View Full Code Here

TOP

Related Classes of org.hibernate.Session$LockRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.