Package org.hibernate

Examples of org.hibernate.Query


    }
   
    Session ssn = getSession();
   
    try{
      Query q = ssn.createQuery(hql.toString()).setCacheable(true);
      q.setTimestamp("beginTime", firstDate.getTime());
      q.setTimestamp("endTime", nextMonthFirstDate.getTime());
      q.setInteger("status", DiaryBean.STATUS_NORMAL);
      q.setInteger("site", site.getId());
      if(!site.isOwner(user)){
        q.setInteger("cat_type", CatalogBean.TYPE_OWNER);
        if(user != null)
          q.setInteger("user", user.getId());
      }
      int total = 0;
      Iterator logs = q.list().iterator();
      while(logs.hasNext()){
        tempCal.setTime((Date)logs.next());
        int date = tempCal.get(Calendar.DATE);
        logCounts[date]++;
        total ++;
View Full Code Here


      hql.append(" AND j.catalog.id=:catalog");
    }
    hql.append(" ORDER BY j.id DESC");
    Session ssn = getSession();
    try{
      Query q = ssn.createQuery(hql.toString());
      q.setInteger("site", site.getId());
      q.setInteger("status", DiaryBean.STATUS_NORMAL);
      q.setInteger("diary", log_id);
      if(cat_id > 0)
        q.setInteger("catalog", cat_id);
      if(!site.isOwner(user)){
        q.setInteger("type", CatalogBean.TYPE_OWNER);
        if(user != null)
          q.setInteger("user", user.getId());
      }
      q.setMaxResults(1);
      return (DiaryOutlineBean)q.uniqueResult();
    }finally{
      hql = null;
    }
  }
View Full Code Here

      hql.append(" AND j.catalog.id=:catalog");
    }
    hql.append(" ORDER BY j.id ASC");
    Session ssn = getSession();
    try{
      Query q = ssn.createQuery(hql.toString());
      q.setInteger("site", site.getId());
      q.setInteger("status", DiaryBean.STATUS_NORMAL);
      q.setInteger("diary", log_id);
      if(cat_id > 0)
        q.setInteger("catalog", cat_id);
      if(!site.isOwner(user)){
        q.setInteger("type", CatalogBean.TYPE_OWNER);
        if(user != null)
          q.setInteger("user", user.getId());
      }
      q.setMaxResults(1);
      return (DiaryOutlineBean)q.uniqueResult();
    }finally{
      hql = null;
    }
  }
View Full Code Here

    if(year > 0 || month > 0 || date > 0){
      hql.append(" AND a.writeTime >= :beginTime AND a.writeTime < :endTime");
    }
    try {
      Session ssn = getSession();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger("status", DiaryBean.STATUS_NORMAL);
      q.setInteger("site", site.getId());
      if(!site.isOwner(user)){
        q.setInteger("cat_type", CatalogBean.TYPE_OWNER);
        if(user != null){
          q.setInteger("user", user.getId());
        }
      }
      if (catalog_id > 0) {
        q.setInteger("catalog", catalog_id);
      }
      if(year > 0 || month > 0 || date > 0){
        Calendar[] cals = genTimeParams(year,month,date);
        q.setTimestamp("beginTime", cals[0].getTime());
        q.setTimestamp("endTime", cals[1].getTime());
      }
      return ((Number) q.uniqueResult()).intValue();
    } finally {
      hql = null;
    }
  }
View Full Code Here

      hql.append(" AND a.writeTime >= :beginTime AND a.writeTime < :endTime");
    }
    hql.append(" ORDER BY a.id DESC");
    try {
      Session ssn = getSession();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger("status", DiaryBean.STATUS_NORMAL);
      q.setInteger("cat_type", CatalogBean.TYPE_OWNER);
      if(year > 0 || month > 0 || date > 0){
        Calendar[] cals = genTimeParams(year,month,date);
        q.setTimestamp("beginTime", cals[0].getTime());
        q.setTimestamp("endTime", cals[1].getTime());
      }
      if(fromIdx>0)
        q.setFirstResult(fromIdx);
      if(count>0)
        q.setMaxResults(count);
      return q.list();
    } finally {
      hql = null;
    }
  }
View Full Code Here

      hql.append(" AND a.writeTime >= :beginTime AND a.writeTime < :endTime");
    }
    hql.append(" ORDER BY a.id DESC");
    try {
      Session ssn = getSession();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger("status", DiaryBean.STATUS_NORMAL);
      q.setInteger("site", site.getId());
      if(user==null || site.getOwner().getId() != user.getId()){
        q.setInteger("cat_type", CatalogBean.TYPE_OWNER);
        if(user != null){
          q.setInteger("user", user.getId());
        }
      }
      if (catalog_id > 0) {
        q.setInteger("catalog", catalog_id);
      }
      if(year > 0 || month > 0 || date > 0){
        Calendar[] cals = genTimeParams(year,month,date);
        q.setTimestamp("beginTime", cals[0].getTime());
        q.setTimestamp("endTime", cals[1].getTime());
      }
      if(fromIdx>0)
        q.setFirstResult(fromIdx);
      if(count>0)
        q.setMaxResults(count);
      return q.list();
    } finally {
      hql = null;
    }
  }
View Full Code Here

   * @param incCount
   * @return
   * @throws SQLException
   */
  static int incTrackBackCount(Session ssn, int log_id, int incCount){
    Query q = ssn.getNamedQuery("INC_DIARY_TB_COUNT");
    q.setInteger(0, incCount);
    q.setInteger(1, log_id);
    return q.executeUpdate();
  }
View Full Code Here

      hql.append(')');
      hql.append(" AND (r.ownerOnly = 0 OR r.user.id = :userid)");
    }
    hql.append(" ORDER BY r.id DESC");
    Session ssn = getSession();
    Query q = ssn.createQuery(hql.toString());
    q.setInteger("status", DiaryReplyBean.STATUS_NORMAL);
    q.setInteger("site", site.getId());
    q.setInteger("diary_status", DiaryOutlineBean.STATUS_NORMAL);
    if(!site.isOwner(user)){
      q.setInteger("cat_type", CatalogBean.TYPE_OWNER);
      q.setInteger("userid", (user!=null)?user.getId():-1);
    }
    if(fromIdx>0)
      q.setFirstResult(fromIdx);
    if(count>0)
      q.setMaxResults(count);
    return q.list();
  }
View Full Code Here

      if(user != null)
        hql.append(" OR (r.diary.catalog.type=? AND r.diary.catalog.id IN (SELECT p.key.catalog FROM CatalogPermBean AS p WHERE p.key.user=?))");
      hql.append(')');
    }
    Session ssn = getSession();
    Query q = ssn.createQuery(hql.toString());
    q.setInteger(0, DiaryReplyBean.STATUS_NORMAL);
    q.setInteger(1, site.getId());
    if(!site.isOwner(user)){
      q.setInteger(2, CatalogBean.TYPE_OWNER);
      if(user != null){
        q.setInteger(3, CatalogBean.TYPE_OWNER);
        q.setInteger(4, user.getId());
      }
    }
    return ((Number)q.uniqueResult()).intValue();
  }
View Full Code Here

    }
    hql.append("?)");
    Session ssn = getSession();
    try{
      beginTransaction();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, ownerId);
      int i=0;
      for(;i<max_msg_count;i++){
        String s_id = (String)msgIds[i];
        int id = -1;
        try{
          id = Integer.parseInt(s_id);
        }catch(Exception e){}
        q.setInteger(i+1, id);
      }
      q.setInteger(i+1, -1);
      int er = q.executeUpdate();
      commit();
      return er;
    }catch(HibernateException e){
      rollback();
      throw e;
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.