📄 forumhibernatedao.java
字号:
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
List list = query.list();
return list;
}
});
}
public List getForumTopicList(final long bid, final long ID2, final short delSign,
final short auditing) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
String q = "from Forum" + SysUtil.getForumTableID(bid) +
" forum where forum.id2 = ? and forum.boardID = ? and forum.delSign = ? and forum.auditing = ? order by forum.id";
Query query = s.createQuery(q);
query.setLong(0, ID2);
query.setLong(1, bid);
query.setShort(2, delSign);
query.setShort(3, auditing);
List list = query.list();
return list;
}
});
}
public int getForumOwnerNum(long bid, long userID) {
String q = "select count(forum.id) from Forum" + SysUtil.getForumTableID(bid) +
" forum where forum.boardID = ? and forum.userID = ?";
try {
Object[] o = {new Long(bid), new Long(userID)};
List l = this.getHibernateTemplate().find(q, o);
if (l != null && !l.isEmpty()) {
return ( (Integer) l.get(0)).intValue();
}
else {
return 0;
}
}
catch (DataAccessException ex) {
logger.error(ex);
return 0;
}
}
public List findForumOwner(final long bid, final long userID, final int firstResult,
final int maxResults) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
String q = "from Forum" + SysUtil.getForumTableID(bid) +
" forum where forum.boardID = ? and forum.userID = ? order by forum.id";
Query query = s.createQuery(q);
query.setLong(0, bid);
query.setLong(1, userID);
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
List list = query.list();
return list;
}
});
}
public List getForumDelTopicList(final long bid, final long ID2) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
String q = "from Forum" + SysUtil.getForumTableID(bid) +
" forum where forum.id2 = ? and forum.boardID = ? and forum.delSign = ? order by forum.id";
Query query = s.createQuery(q);
query.setLong(0, ID2);
query.setLong(1, bid);
query.setShort(2, (short) 1);
List list = query.list();
return list;
}
});
}
/**
* findForumInList
*
* @param bid long
* @param values List
* @return List
* @todo Implement this com.laoer.bbscs.dao.IForumDAO method
*/
public List findForumInList(final long bid, final List values) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
String q = "from Forum" + SysUtil.getForumTableID(bid) +
" forum where forum.id in (:values) and forum.boardID = :bid";
Query query = s.createQuery(q);
query.setParameterList("values", values);
query.setLong("bid", bid);
List list = query.list();
return list;
}
});
}
/**
* findForumDelAll
*
* @param bid long
* @return List
* @todo Implement this com.laoer.bbscs.dao.IForumDAO method
*/
public List findForumDelAll(long bid) {
String q = "from Forum" + SysUtil.getForumTableID(bid) +
" forum where forum.boardID = ? and forum.delSign = 1 and forum.delTime < ?";
Object[] o = {
new Long(bid), new Long(SysUtil.getLongTime() - 7 * 24 * 3600 * 1000)};
try {
return this.getHibernateTemplate().find(q, o);
}
catch (DataAccessException ex) {
logger.error(ex);
return new ArrayList();
}
}
public List findForumDelAllList(final long bid, final int firstResult, final int maxResults) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
String q = "from Forum" + SysUtil.getForumTableID(bid) +
" forum where forum.boardID = ? and forum.delSign = ? order by forum.id desc";
Query query = s.createQuery(q);
query.setLong(0, bid);
query.setShort(1, (short) 1);
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
List list = query.list();
return list;
}
});
}
public List findForumElite(long bid, long elite, long eliteId) {
String q = "from Forum" + SysUtil.getForumTableID(bid) +
" forum where forum.boardID = ? and forum.elite = ? and forum.eliteID = ?";
Object[] o = {
new Long(bid), new Long(elite), new Long(eliteId)};
try {
return this.getHibernateTemplate().find(q, o);
}
catch (DataAccessException ex) {
logger.error(ex);
return new ArrayList();
}
}
/**
* removeForum
*
* @param id long
* @param bid long
* @todo Implement this com.laoer.bbscs.dao.IForumDAO method
*/
public void removeForum(final long id, final long bid) {
getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
String q = "from Forum" + SysUtil.getForumTableID(bid) +
" forum where forum.id = ? and forum.boardID = ?";
Object[] o = {
new Long(id), new Long(bid)};
Type[] t = {
Hibernate.LONG, Hibernate.LONG};
s.delete(q, o, t);
return null;
}
});
}
public void removeForum(Forum forum) {
try {
getHibernateTemplate().delete(forum);
}
catch (DataAccessException ex) {
logger.error(ex);
}
}
public int getSearchNum(long bid, String con, String text) {
StringBuffer sb = new StringBuffer();
sb.append("select count(forum.id) from Forum");
sb.append(SysUtil.getForumTableID(bid));
sb.append(" forum where forum.boardID = ? and forum.");
sb.append(con);
sb.append(" like ?");
//sb.append(" like '%");
//sb.append(text);
//sb.append("%'");
try {
Object[] o = {
new Long(bid), "%" + text + "%"};
List l = getHibernateTemplate().find(sb.toString(), o);
if (l != null && !l.isEmpty()) {
return ( (Integer) l.get(0)).intValue();
}
else {
return 0;
}
}
catch (DataAccessException ex) {
logger.error(ex);
return 0;
}
}
public List getSearchList(final long bid, final String con, final String text,
final int firstResult,
final int maxResults) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
StringBuffer sb = new StringBuffer();
sb.append("from Forum");
sb.append(SysUtil.getForumTableID(bid));
sb.append(" forum where forum.boardID = ? and forum.");
sb.append(con);
sb.append(" like ? order by forum.id desc");
Query query = s.createQuery(sb.toString());
query.setLong(0, bid);
query.setString(1, "%" + text + "%");
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
List l = query.list();
return l;
}
});
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -