📄 commendimpl.java
字号:
/*
* Created on 2006-2-8
* Last modified on 2007-1-21
* Powered by YeQiangWei.com
*/
package com.yeqiangwei.club.dao.hibernate.impl;
import java.util.List;
import com.yeqiangwei.club.dao.CommendDAO;
import com.yeqiangwei.club.dao.hibernate.support.HibernateFacade;
import com.yeqiangwei.club.dao.model.Commend;
import com.yeqiangwei.club.param.CommendParameter;
/**
* 推荐帖系统
* @author YeQiangWei Studio by 我容易么我
*/
public class CommendImpl implements CommendDAO{
private static final String FIND_COMMENDID = "from Commend where commendId=?";
private static final String DELETE_COMMENDID = "delete from Commend where commendId=?";
private static final String DELETES_COMMENDID = "delete from Commend where commendId in (:ids)";
public Commend create(Commend item) {
HibernateFacade<Commend> facade = new HibernateFacade<Commend>();
facade.save(item);
return item;
}
public Commend update(Commend item) {
HibernateFacade<Commend> facade = new HibernateFacade<Commend>();
item = facade.update(item);
return item;
}
public int delete(Commend item) {
HibernateFacade<Commend> facade = new HibernateFacade<Commend>();
facade.createQuery(DELETE_COMMENDID);
facade.setInt(0,item.getCommendId());
int c = facade.executeUpdate();
return c;
}
public int delete(List ids) {
HibernateFacade<Commend> facade = new HibernateFacade<Commend>();
facade.createQuery(DELETES_COMMENDID);
facade.setParameterList("ids",ids);
int c = facade.executeUpdate();
return c;
}
public Commend findById(int id) {
HibernateFacade<Commend> facade = new HibernateFacade<Commend>();
facade.createQuery(FIND_COMMENDID);
facade.setInt(0,id);
Commend item = facade.uniqueResult();
return item;
}
public List<Commend> findByParameter(CommendParameter param) {
StringBuffer hql = new StringBuffer();
hql.append("from Commend where commendId>0 ");
if(param.getType()!=null){
hql.append(" and type=");
hql.append(param.getType().byteValue());
}
if(param.getForumId()!=null){
hql.append(" and forumId=");
hql.append(param.getForumId().intValue());
}
if(param.getIsPassed()!=null){
hql.append(" and isPassed=?");
}
hql.append(" order commendId desc");
HibernateFacade<Commend> facade = new HibernateFacade<Commend>();
facade.createQuery(hql);
if(param.getIsPassed()!=null){
facade.setBoolean(0,param.getIsPassed().booleanValue());
}
facade.setFirstResult(param.getPagination().getStartRow());
facade.setMaxResults(param.getPagination().getEndRow());
List<Commend> list = facade.executeQuery();
return list;
}
public long countByParameter(CommendParameter param) {
StringBuffer hql = new StringBuffer();
hql.append("select count(commendId) from Commend where commendId>0 ");
if(param.getType()!=null){
hql.append(" and type=");
hql.append(param.getType().byteValue());
}
if(param.getForumId()!=null){
hql.append(" and forumId=");
hql.append(param.getForumId().intValue());
}
if(param.getIsPassed()!=null){
hql.append(" and isPassed=?");
}
HibernateFacade<Commend> facade = new HibernateFacade<Commend>();
facade.createQuery(hql);
if(param.getIsPassed()!=null){
facade.setBoolean(0,param.getIsPassed().booleanValue());
}
long c = facade.resultTotal();
return c;
}
public List findAll(CommendParameter param) {
return null;
}
public long countAll(CommendParameter param) {
return 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -