?? sysnumstathibernatedao.java
字號(hào):
package com.laoer.bbscs.dao.hibernate;
import org.springframework.orm.hibernate.support.*;
import com.laoer.bbscs.dao.ISysNumStatDAO;
import com.laoer.bbscs.bean.SysNumStat;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
import org.springframework.dao.*;
import java.util.*;
import net.sf.hibernate.Query;
import net.sf.hibernate.Session;
import net.sf.hibernate.HibernateException;
import org.springframework.orm.hibernate.HibernateCallback;
import java.sql.SQLException;
/**
* <p>Title: TianYi BBS</p>
*
* <p>Description: TianYi BBS System</p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: LAOER.COM/TIANYISOFT.NET</p>
*
* @author laoer
* @version 6.0
*/
public class SysNumStatHibernateDAO
extends HibernateDaoSupport implements ISysNumStatDAO {
private static final Log logger = LogFactory.getLog(SysNumStatHibernateDAO.class);
private static final String LOAD_BY_RECDATE =
"from SysNumStat sns where sns.recDate = ?";
private static final String LOADS_ALL =
"from SysNumStat sns order by sns.id desc";
private static final String LOADS_ALL_COUNT =
"from SysNumStat sns";
public SysNumStatHibernateDAO() {
super();
}
/**
* saveSysNumStat
*
* @param sns SysNumStat
* @return SysNumStat
* @todo Implement this com.laoer.bbscs.dao.ISysNumStatDAO method
*/
public SysNumStat saveSysNumStat(SysNumStat sns) {
try {
this.getHibernateTemplate().saveOrUpdate(sns);
return sns;
}
catch (DataAccessException ex) {
return null;
}
}
/**
* findSysNumStatByRecDate
*
* @param recDate String
* @return SysNumStat
* @todo Implement this com.laoer.bbscs.dao.ISysNumStatDAO method
*/
public SysNumStat findSysNumStatByRecDate(String recDate) {
List l = this.getHibernateTemplate().find(LOAD_BY_RECDATE, recDate);
if (l == null || l.size() == 0 || l.isEmpty()) {
return null;
}
else {
return (SysNumStat) l.get(0);
}
}
/**
* getSysNumStatNum
*
* @return int
* @todo Implement this com.laoer.bbscs.dao.ISysNumStatDAO method
*/
public int getSysNumStatNum() {
try {
List l = this.getHibernateTemplate().find("select count(*) " + LOADS_ALL_COUNT);
return ( (Integer) l.get(0)).intValue();
}
catch (DataAccessException ex) {
logger.error(ex);
return 0;
}
}
/**
* getSysNumStatList
*
* @param pages Pages
* @return PageList
* @todo Implement this com.laoer.bbscs.dao.ISysNumStatDAO method
*/
public List getSysNumStatList(final int firstResult, final int maxResults) {
return getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
Query query = s.createQuery(LOADS_ALL);
query.setFirstResult(firstResult);
query.setMaxResults(maxResults);
List list = query.list();
return list;
}
});
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -