Package org.hibernate

Examples of org.hibernate.Query


    int i=0;
    for(;i<ids.size();i++){
      hql.append("?,");
    }
    hql.append("?) ORDER BY m.id DESC");     
    Query q = ssn.createQuery(hql.toString());
    for(i=0;i<ids.size();i++){
      int id = ((Number)ids.get(i)).intValue();
      q.setInteger(i, id);
    }
    q.setInteger(i, -1);
    return q.list();
  }
View Full Code Here


   * @param key
   * @return
   */
  public static List search(String key){
    Session ssn = getSession();
    Query q = ssn.getNamedQuery("SEARCH_MUSIC");
    String pattern = '%' + key + '%';
    q.setString("key", pattern);
    q.setMaxResults(20);
    List res = q.list();
    List songs = new ArrayList();
    for(int i=0;res!=null&&i<res.size();i++){
      Object[] objs = (Object[])res.get(i);
      MusicBean mbean = new MusicBean();
      mbean.setTitle((String)objs[0]);
View Full Code Here

        hql.append("?,");
        hql2.append("?,");
      }
      hql.append("?)")
      hql2.append("?)");     
      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, siteid);
      i=0;
      for(;i<ids.length;i++){
        q.setInteger(i+1, ids[i]);
      }
      q.setInteger(i+1, ids[0]);
      List musics = q.list();
      if(musics.size()>0){
        beginTransaction();
        //����ռ��жԸ����ֵ�����
        Query q2 = ssn.createQuery(hql2.toString());
        i=0;
        q2.setParameter(0, null);
        for(;i<ids.length;i++){
          q2.setInteger(i+1, ids[i]);
        }
        q2.setInteger(i+1, ids[0]);
        q2.executeUpdate();
        //ɾ������
        for(i=0;i<musics.size();i++){
          MusicBean mbean = (MusicBean)musics.get(i);
          if(mbean.getMusicBox()!=null)
            mbean.getMusicBox().incMusicCount(-1);
View Full Code Here

      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);
      if(!is_owner)
        q.setInteger("album_type", AlbumBean.TYPE_PUBLIC);     
      q.setMaxResults(1);
      return (PhotoOutlineBean)q.uniqueResult();
    }finally{
      hql = null;
    }
  }
View Full Code Here

      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);
      if(!site.isOwner(user))
        q.setInteger("album_type", AlbumBean.TYPE_PUBLIC);     
      q.setMaxResults(1);
      return (PhotoOutlineBean)q.uniqueResult();
    }finally{
      hql = null;
    }
  }
View Full Code Here

      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);
        q.setInteger("month", month_stamp % 100);
      }
      if(user==null || site.getOwner().getId()!=user.getId()){
        q.setInteger("hidden_status", PhotoBean.STATUS_PRIVATE);
        q.setInteger("owner_album", AlbumBean.TYPE_PUBLIC);
      }
      if(date>0){
        q.setInteger("date", date);
      }
      q.setFirstResult(fromIdx);
      q.setMaxResults(count);
      return q.list();
    }finally{
      hql = null;
    }
  }
View Full Code Here

   * @param fromIdx
   * @param count
   * @return
   */
  public static List listPhotos(AlbumBean album, int fromIdx, int count){
    Query q = getSession().getNamedQuery("PHOTOS_OF_ALBUM");
    q.setInteger("album", album.getId());
    //q.setInteger("hidden_status", PhotoBean.STATUS_PRIVATE);
    if(fromIdx > 0)
      q.setFirstResult(fromIdx);
    if(count > 0)
      q.setMaxResults(count);
    return q.list();
  }
View Full Code Here

      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);
      }
      q.setInteger("hidden_status", PhotoBean.STATUS_PRIVATE);
      q.setInteger("owner_album", AlbumBean.TYPE_PUBLIC);
      if(date>0){
        q.setInteger("date", date);
      }
      q.setInteger("site_status", SiteBean.STATUS_NORMAL);
      q.setFirstResult(fromIdx);
      q.setMaxResults(count);
      return q.list();
    }finally{
      hql = null;
    }
  }
View Full Code Here

    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);
        q.setInteger("month", month_stamp % 100);
      }
      if(!is_owner){
        q.setInteger("normal_status", PhotoBean.STATUS_NORMAL);
        q.setInteger("public_album", AlbumBean.TYPE_PUBLIC);
      }
      if(date>0){
        q.setInteger("date", date);
      }
      return ((Number)q.uniqueResult()).intValue();
    }finally{
      hql = null;
    }
  }
View Full Code Here

      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();
      return (size!=null)?size.intValue():0;
    }finally{
      hql = null;
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.Query

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.