📄 forumhibernatedao.java
字号:
c.add(Restrictions.ge("reNum", new Integer(reNum)));
}
if (click != -1) {
c.add(Restrictions.eq("click", new Integer(click)));
}
if (commend != -1) {
c.add(Restrictions.eq("commend", new Long(commend)));
}
//c.add(Restrictions.eq("isNew", new Integer(1)));
c.add(Restrictions.eq("delSign", new Integer(0)));
c.add(Restrictions.eq("auditing", new Integer(0)));
if (StringUtils.isNotBlank(orderby)) {
if (ascOrDesc == Constant.ORDER_ASC) {
c.addOrder(Order.asc(orderby));
}
if (ascOrDesc == Constant.ORDER_DESC) {
c.addOrder(Order.desc(orderby));
}
}
c.setFirstResult(firstResult);
c.setMaxResults(maxResults);
return c.list();
}
});
}
/**
*
* @param bid long
* @param reNum int
* @param click int
* @param commend int
* @return int
*/
public int getForumNumRcc(final long bid, final int reNum, final int click, final long commend) {
List l = getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException {
Criteria c = s.createCriteria(Forum.class);
c.setProjection(Projections.count("id"));
c.add(Restrictions.eq("boardID", new Long(bid)));
if (reNum != -1) {
c.add(Restrictions.ge("reNum", new Integer(reNum)));
}
if (click != -1) {
c.add(Restrictions.ge("click", new Integer(click)));
}
if (commend != -1) {
c.add(Restrictions.eq("commend", new Long(commend)));
}
//c.add(Restrictions.eq("isNew", new Integer(1)));
c.add(Restrictions.eq("delSign", new Integer(0)));
c.add(Restrictions.eq("auditing", new Integer(0)));
return c.list();
}
});
if (l == null || l.isEmpty()) {
return 0;
}
else {
return ( (Integer) l.get(0)).intValue();
}
}
public List findForumsRcc(final long bid, final int reNum, final int click, final long commend,
final String orderby, final int ascOrDesc, final int firstResult,
final int maxResults) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException {
Criteria c = s.createCriteria(Forum.class);
c.add(Restrictions.eq("boardID", new Long(bid)));
if (reNum != -1) {
c.add(Restrictions.ge("reNum", new Integer(reNum)));
}
if (click != -1) {
c.add(Restrictions.ge("click", new Integer(click)));
}
if (commend != -1) {
c.add(Restrictions.eq("commend", new Long(commend)));
}
//c.add(Restrictions.eq("isNew", new Integer(1)));
c.add(Restrictions.eq("delSign", new Integer(0)));
c.add(Restrictions.eq("auditing", new Integer(0)));
if (StringUtils.isNotBlank(orderby)) {
if (ascOrDesc == Constant.ORDER_ASC) {
c.addOrder(Order.asc(orderby));
}
if (ascOrDesc == Constant.ORDER_DESC) {
c.addOrder(Order.desc(orderby));
}
}
c.setFirstResult(firstResult);
c.setMaxResults(maxResults);
return c.list();
}
});
}
public int getForumNumCommend(final long commend) {
List l = getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException {
Criteria c = s.createCriteria(Forum.class);
c.setProjection(Projections.count("id"));
if (commend != -1) {
c.add(Restrictions.eq("commend", new Long(commend)));
}
c.add(Restrictions.eq("delSign", new Integer(0)));
c.add(Restrictions.eq("auditing", new Integer(0)));
return c.list();
}
});
if (l == null || l.isEmpty()) {
return 0;
}
else {
return ( (Integer) l.get(0)).intValue();
}
}
public List findForumsCommend(final long commend, final String orderby, final int ascOrDesc,
final int firstResult, final int maxResults) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException {
Criteria c = s.createCriteria(Forum.class);
if (commend != -1) {
c.add(Restrictions.eq("commend", new Long(commend)));
}
c.add(Restrictions.eq("delSign", new Integer(0)));
c.add(Restrictions.eq("auditing", new Integer(0)));
if (StringUtils.isNotBlank(orderby)) {
if (ascOrDesc == Constant.ORDER_ASC) {
c.addOrder(Order.asc(orderby));
}
if (ascOrDesc == Constant.ORDER_DESC) {
c.addOrder(Order.desc(orderby));
}
}
c.setFirstResult(firstResult);
c.setMaxResults(maxResults);
return c.list();
}
});
}
public int getForumNumHotTopic(long bid, int reNum, int click) {
Object[] o = {new Long(bid), new Integer(1), new Integer(0), new Integer(0), new Integer(reNum),
new Integer(click)};
List l = this.getHibernateTemplate().find(GET_NUM_HOT, o);
if (l == null || l.isEmpty()) {
return 0;
}
else {
return ( (Integer) l.get(0)).intValue();
}
}
public List findForumsHotTopic(final long bid, final int reNum, final int click, final int firstResult,
final int maxResults) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
Query query = s.createQuery(LOADS_HOT);
query.setLong(0, bid);
query.setInteger(1, 1);
query.setInteger(2, 0);
query.setInteger(3, 0);
query.setInteger(4, reNum);
query.setInteger(5, click);
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
List list = query.list();
return list;
}
});
}
/**
*
* @param bids List
* @param reNum int
* @param click int
* @return int
*/
public int getForumNumHotTopic(final List bids, final int reNum, final int click) {
List l = getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
Query query = s.createQuery(GET_NUM_HOT_IN_BIDS);
query.setParameterList("bids", bids);
query.setInteger("isNew", 1);
query.setInteger("delSign", 0);
query.setInteger("auditing", 0);
query.setInteger("reNum", reNum);
query.setInteger("click", click);
List list = query.list();
return list;
}
});
if (l == null || l.isEmpty()) {
return 0;
}
else {
return ( (Integer) l.get(0)).intValue();
}
}
/**
*
* @param bids List
* @param reNum int
* @param click int
* @param firstResult int
* @param maxResults int
* @return List
*/
public List findForumsHotTopic(final List bids, final int reNum, final int click, final int firstResult,
final int maxResults) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
Query query = s.createQuery(LOADS_HOT_IN_BIDS);
query.setParameterList("bids", bids);
query.setInteger("isNew", 1);
query.setInteger("delSign", 0);
query.setInteger("auditing", 0);
query.setInteger("reNum", reNum);
query.setInteger("click", click);
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
List list = query.list();
return list;
}
});
}
public List findForumsToHistory(long atime) {
return this.getHibernateTemplate().find(LOADS_TO_HISTORY, new Long(atime));
}
public int getForumNumInMainIDByUserID(final long bid, final String mainID, final String userID,
final int isnew, final int delSign, final int auditing) {
List l = getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException {
Criteria c = s.createCriteria(Forum.class);
c.setProjection(Projections.count("id"));
c.add(Restrictions.eq("boardID", new Long(bid)));
c.add(Restrictions.eq("mainID", mainID));
c.add(Restrictions.eq("userID", userID));
if (isnew != -1) {
c.add(Restrictions.eq("isNew", new Integer(isnew)));
}
if (delSign != -1) {
c.add(Restrictions.eq("delSign", new Integer(delSign)));
}
if (auditing != -1) {
c.add(Restrictions.eq("auditing", new Integer(auditing)));
}
return c.list();
}
});
if (l == null || l.isEmpty()) {
return 0;
}
else {
return ( (Integer) l.get(0)).intValue();
}
}
public List findForumsInMainIDByUserID(final long bid, final String mainID, final String userID,
final int isnew, final int delSign, final int auditing,
final String orderby, final int ascOrDesc,
final int firstResult, final int maxResults) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException {
Criteria c = s.createCriteria(Forum.class);
c.add(Restrictions.eq("boardID", new Long(bid)));
c.add(Restrictions.eq("mainID", mainID));
c.add(Restrictions.eq("userID", userID));
if (isnew != -1) {
c.add(Restrictions.eq("isNew", new Integer(isnew)));
}
if (delSign != -1) {
c.add(Restrictions.eq("delSign", new Integer(delSign)));
}
if (auditing != -1) {
c.add(Restrictions.eq("auditing", new Integer(auditing)));
}
if (StringUtils.isNotBlank(orderby)) {
if (ascOrDesc == Constant.ORDER_ASC) {
c.addOrder(Order.asc(orderby));
}
if (ascOrDesc == Constant.ORDER_DESC) {
c.addOrder(Order.desc(orderby));
}
}
c.setFirstResult(firstResult);
c.setMaxResults(maxResults);
return c.list();
}
});
}
public List findForumsInIds(final long bid, final List ids) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
Query query = s.createQuery(LOADS_IN_IDS_BID);
query.setParameterList("ids", ids);
query.setLong("bid", bid);
List list = query.list();
return list;
}
});
}
public List findForumsInIds(final List ids) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
Query query = s.createQuery(LOADS_IN_IDS);
query.setParameterList("ids", ids);
List list = query.list();
return list;
}
});
}
public List findForumsRealDelAll(long bid, long atime) {
Object[] o = {new Long(bid), new Long(atime)};
return this.getHibernateTemplate().find(LOADS_DEL_REAL_ALL, o);
}
public List findForumsByIndexStatus(int indexStatus) {
return this.getHibernateTemplate().find(LOADS_BY_INDEX_STATUS, new Integer(indexStatus));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -