afficheimpl.java
来自「社区文章采用的是平板、树形自由选择的两种展示方式」· Java 代码 · 共 107 行
JAVA
107 行
/*
* Created on 2005-10-31
* Last modified on 2007-12-20
* Powered by YeQiangWei.com
*/
package com.yeqiangwei.club.dao.hibernate.impl;
import java.util.List;
import com.yeqiangwei.club.dao.AfficheDAO;
import com.yeqiangwei.club.dao.hibernate.support.HibernateFacade;
import com.yeqiangwei.club.dao.hibernate.support.HibernateProvider;
import com.yeqiangwei.club.model.Affiche;
import com.yeqiangwei.club.param.AfficheParameter;
public class AfficheImpl implements AfficheDAO{
private static final String FIND_AFFICHEID = "from Affiche where afficheId=?";
private static final String FIND_ALL = "from Affiche order by afficheId desc";
private static final String COUNT_ALL = "select count(afficheId) from Affiche order by afficheId desc";
private static final String DELETE_AFFICHEID = "delete from Affiche where afficheId=?";
private static final String DELETES_AFFICHEID = "delete from Affiche where afficheId in (:ids)";
public void create(Affiche item) {
HibernateProvider<Affiche> facade = new HibernateFacade<Affiche>();
facade.save(item);
}
public void update(Affiche item) {
HibernateProvider<Affiche> facade = new HibernateFacade<Affiche>();
facade.update(item);
}
public int delete(Affiche item) {
HibernateProvider<Affiche> facade = new HibernateFacade<Affiche>();
facade.createQuery(DELETE_AFFICHEID);
facade.setInt(0, item.getAfficheId());
return facade.executeUpdate();
}
public int delete(List<Integer> ids) {
HibernateProvider<Affiche> facade = new HibernateFacade<Affiche>();
facade.createQuery(DELETES_AFFICHEID);
facade.setParameterList("ids", ids);
return facade.executeUpdate();
}
public Affiche findById(int id) {
HibernateFacade<Affiche> facade = new HibernateFacade<Affiche>(FIND_AFFICHEID);
facade.setInt(0, id);
facade.setCacheable(true);
facade.setMaxResults(1);
return facade.uniqueResult();
}
public List<Affiche> findByParameter(AfficheParameter param) {
StringBuffer hql = new StringBuffer();
hql.append("from Affiche ");
if(param.getForumId()!=null){
hql.append(" where forumId=");
hql.append(param.getForumId().intValue());
hql.append(" or forumId=-1");
}
hql.append(" order by afficheId desc");
HibernateProvider<Affiche> facade = new HibernateFacade<Affiche>();
facade.createQuery(hql);
facade.setFirstResult(param.getPagination().getStartRow());
facade.setMaxResults(param.getPagination().getEndRow());
return facade.executeQuery();
}
public long countByParameter(AfficheParameter param) {
StringBuffer hql = new StringBuffer();
hql.append("select count(afficheId) from Affiche ");
if(param.getForumId()!=null){
hql.append(" where forumId=");
hql.append(param.getForumId().intValue());
hql.append(" or forumId=-1");
}
hql.append(" order by afficheId desc");
HibernateProvider<Affiche> facade = new HibernateFacade<Affiche>();
facade.createQuery(hql);
return facade.resultTotal();
}
public List<Affiche> findAll(AfficheParameter param) {
HibernateProvider<Affiche> facade = new HibernateFacade<Affiche>();
facade.createQuery(FIND_ALL);
facade.setFirstResult(param.getPagination().getStartRow());
facade.setMaxResults(param.getPagination().getEndRow());
return facade.executeQuery();
}
public long countAll(AfficheParameter param) {
HibernateProvider<Affiche> facade = new HibernateFacade<Affiche>();
facade.createQuery(COUNT_ALL);
return facade.resultTotal();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?