📄 forumhibernatedao.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: ForumHibernateDAO.java
package com.laoer.bbscs.dao.hibernate;
import com.laoer.bbscs.bean.Forum;
import com.laoer.bbscs.dao.IForumDAO;
import com.laoer.bbscs.sys.SysUtil;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import net.sf.hibernate.*;
import net.sf.hibernate.type.Type;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate.HibernateCallback;
import org.springframework.orm.hibernate.HibernateTemplate;
import org.springframework.orm.hibernate.support.HibernateDaoSupport;
public class ForumHibernateDAO extends HibernateDaoSupport
implements IForumDAO
{
private static final Log logger;
static Class class$com$laoer$bbscs$dao$hibernate$ForumHibernateDAO; /* synthetic field */
public ForumHibernateDAO()
{
}
public Forum saveForum(Forum forum)
{
getHibernateTemplate().saveOrUpdate(forum);
return forum;
DataAccessException ex;
ex;
logger.error("saveForum(Forum forum):" + ex);
return null;
}
public Forum getForum(long id, final long bid)
{
return (Forum)getHibernateTemplate().execute(id. new HibernateCallback() {
public Object doInHibernate(Session s)
throws HibernateException, SQLException
{
String className = SysUtil.getForumClassName(bid);
return s.get(Class.forName(className), new Long(id));
ClassNotFoundException ex;
ex;
ForumHibernateDAO.logger.error(ex);
return null;
ex;
ForumHibernateDAO.logger.error(ex);
return null;
}
});
}
public int getForumMainNum(long bid)
{
String q = "select count(forum.id) from Forum" + SysUtil.getForumTableID(bid) + " forum where forum.boardID = ? and forum.isNew = 1 and forum.delSign = 0 and forum.auditing = 0";
List l = getHibernateTemplate().find(q, new Long(bid));
if(l != null && !l.isEmpty())
return ((Integer)l.get(0)).intValue();
return 0;
DataAccessException ex;
ex;
logger.error(ex);
return 0;
}
public int getForumAllNum(long bid, short delSign, short auditing)
{
String q;
Object o[];
q = "select count(forum.id) from Forum" + SysUtil.getForumTableID(bid) + " forum where forum.boardID = ? and forum.delSign = ? and forum.auditing = ?";
o = (new Object[] {
new Long(bid), new Short(delSign), new Short(auditing)
});
List l = getHibernateTemplate().find(q, o);
if(l != null && !l.isEmpty())
return ((Integer)l.get(0)).intValue();
return 0;
DataAccessException ex;
ex;
logger.error(ex);
return 0;
}
public int getForumTopicNum(long bid, long ID2)
{
String q;
Object o[];
q = "select count(forum.id) from Forum" + SysUtil.getForumTableID(bid) + " forum where forum.id2 = ? and forum.boardID = ? and forum.delSign = 0 and forum.auditing = 0";
o = (new Object[] {
new Long(ID2), new Long(bid)
});
List l = getHibernateTemplate().find(q, o);
if(l != null && !l.isEmpty())
return ((Integer)l.get(0)).intValue();
return 0;
DataAccessException ex;
ex;
logger.error(ex);
return 0;
}
public int getForumDelAllNum(long bid)
{
String q = "select count(forum.id) from Forum" + SysUtil.getForumTableID(bid) + " forum where forum.boardID = ? and forum.delSign = 1";
List l = getHibernateTemplate().find(q, new Long(bid));
if(l != null && !l.isEmpty())
return ((Integer)l.get(0)).intValue();
return 0;
DataAccessException ex;
ex;
logger.error(ex);
return 0;
}
public List getForumMainList(final long bid, final int firstResult, int maxResults)
{
return getHibernateTemplate().executeFind(maxResults. new HibernateCallback() {
public Object doInHibernate(Session s)
throws HibernateException, SQLException
{
String q = "from Forum" + SysUtil.getForumTableID(bid) + " forum where forum.boardID = ? and forum.isNew = 1 and forum.delSign = 0 and forum.auditing = 0 order by forum.isTop desc,forum.lastTime desc";
Query query = s.createQuery(q);
query.setLong(0, bid);
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
List list = query.list();
return list;
}
});
}
public List getForumAllList(final long bid, final short delSign, final short auditing, final int firstResult, int maxResults)
{
return getHibernateTemplate().executeFind(maxResults. new HibernateCallback() {
public Object doInHibernate(Session s)
throws HibernateException, SQLException
{
String q = "from Forum" + SysUtil.getForumTableID(bid) + " forum where forum.boardID = ? and forum.delSign = ? and forum.auditing = ? order by forum.id desc";
Query query = s.createQuery(q);
query.setLong(0, bid);
query.setShort(1, delSign);
query.setShort(2, auditing);
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
List list = query.list();
return list;
}
});
}
public List getForumTopicList(final long bid, final long ID2, final int firstResult, int maxResults)
{
return getHibernateTemplate().executeFind(maxResults. 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 = 0 and forum.auditing = 0 order by forum.id";
Query query = s.createQuery(q);
query.setLong(0, ID2);
query.setLong(1, bid);
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
List list = query.list();
return list;
}
});
}
public List getForumTopicList(final long bid, final long ID2, final short delSign, short auditing)
{
return getHibernateTemplate().executeFind(auditing. 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 List getForumDelTopicList(final long bid, long ID2)
{
return getHibernateTemplate().executeFind(ID2. 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;
}
});
}
public List findForumInList(final long bid, List values)
{
return getHibernateTemplate().executeFind(values. 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;
}
});
}
public List findForumDelAll(long bid)
{
String q;
Object o[];
q = "from Forum" + SysUtil.getForumTableID(bid) + " forum where forum.boardID = ? and forum.delSign = 1 and forum.delTime < ?";
o = (new Object[] {
new Long(bid), new Long(SysUtil.getLongTime() - 0x240c8400L)
});
return getHibernateTemplate().find(q, o);
DataAccessException ex;
ex;
logger.error(ex);
return new ArrayList();
}
public List findForumDelAllList(final long bid, final int firstResult, int maxResults)
{
return getHibernateTemplate().executeFind(maxResults. 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;
Object o[];
q = "from Forum" + SysUtil.getForumTableID(bid) + " forum where forum.boardID = ? and forum.elite = ? and forum.eliteID = ?";
o = (new Object[] {
new Long(bid), new Long(elite), new Long(eliteId)
});
return getHibernateTemplate().find(q, o);
DataAccessException ex;
ex;
logger.error(ex);
return new ArrayList();
}
public void removeForum(long id, final long bid)
{
getHibernateTemplate().execute(id. 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;
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 ?");
List l;
Object o[] = {
new Long(bid), "%" + text + "%"
};
l = getHibernateTemplate().find(sb.toString(), o);
if(l != null && !l.isEmpty())
return ((Integer)l.get(0)).intValue();
return 0;
DataAccessException ex;
ex;
logger.error(ex);
return 0;
}
public List getSearchList(final long bid, final String con, final String text, final int firstResult, int maxResults)
{
return getHibernateTemplate().executeFind(maxResults. 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;
}
});
}
static Class class$(String x0)
{
return Class.forName(x0);
ClassNotFoundException x1;
x1;
throw new NoClassDefFoundError(x1.getMessage());
}
static
{
logger = LogFactory.getLog(class$com$laoer$bbscs$dao$hibernate$ForumHibernateDAO != null ? class$com$laoer$bbscs$dao$hibernate$ForumHibernateDAO : (class$com$laoer$bbscs$dao$hibernate$ForumHibernateDAO = class$("com.laoer.bbscs.dao.hibernate.ForumHibernateDAO")));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -