?? voteuserhibernatedao.java
字號:
package src.com.laoer.bbscs.dao.hibernate;
import org.springframework.orm.hibernate.support.HibernateDaoSupport;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.dao.*;
import com.laoer.comm.util.*;
import java.util.*;
import net.sf.hibernate.*;
import org.springframework.orm.hibernate.HibernateCallback;
import src.com.laoer.bbscs.bean.VoteUser;
import src.com.laoer.bbscs.dao.IVoteUserDAO;
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 VoteUserHibernateDAO
extends HibernateDaoSupport implements IVoteUserDAO {
private static final Log logger = LogFactory.getLog(VoteUserHibernateDAO.class);
private static final String LOAD_VOTEID_UID =
"from VoteUser vu where vu.voteID = ? and vu.voteUserID = ? and vu.voteTime > ?";
private static final String DEL_OUTTIME =
"from VoteUser vu where vu.voteTime < ?";
public VoteUserHibernateDAO() {
super();
}
/**
* saveVoteUser
*
* @param vu VoteUser
* @return VoteUser
* @todo Implement this com.laoer.bbscs.dao.IVoteUserDAO method
*/
public VoteUser saveVoteUser(VoteUser vu) {
try {
this.getHibernateTemplate().saveOrUpdate(vu);
return vu;
}
catch (DataAccessException ex) {
logger.error(ex);
return null;
}
}
/**
* findVoteUser
*
* @param voteID long
* @param userID long
* @return VoteUser
* @todo Implement this com.laoer.bbscs.dao.IVoteUserDAO method
*/
public VoteUser findVoteUser(long voteID, long userID) {
Object[] o = {
new Long(voteID), new Long(userID),
new Long(Util.getLongTime() - 24 * 3600000)};
try {
List l = this.getHibernateTemplate().find(LOAD_VOTEID_UID, o);
if (l != null && !l.isEmpty()) {
return (VoteUser) l.get(0);
}
else {
return null;
}
}
catch (DataAccessException ex) {
logger.error(ex);
return null;
}
}
/**
* delOutTime
*
* @todo Implement this com.laoer.bbscs.dao.IVoteUserDAO method
*/
public void delOutTime() {
getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session s) throws HibernateException, SQLException {
s.delete(DEL_OUTTIME, new Long(Util.getLongTime() - 24 * 3600000), Hibernate.LONG);
return null;
}
});
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -