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;
}
}