⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 afficheimpl.java

📁 详细的建站源码 详细的建站源码 详细的建站源码 详细的建站源码
💻 JAVA
字号:
/*
 * Created on 2005-10-31
 * Last modified on 2007-1-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.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 Affiche create(Affiche item) {
		HibernateFacade<Affiche> facade = new HibernateFacade<Affiche>();
		item = facade.save(item);		
		return item;
	}
				
    public Affiche update(Affiche item) {
        HibernateFacade<Affiche> facade = new HibernateFacade<Affiche>();
        item = facade.update(item);
        return item; 
    }
    
    public int delete(Affiche item) {
    	HibernateFacade<Affiche> facade = new HibernateFacade<Affiche>();
		facade.createQuery(DELETE_AFFICHEID);
		facade.setInt(0, item.getAfficheId());
		int c = facade.executeUpdate();
		return c;
    }
    
	public int delete(List ids) {
		HibernateFacade<Affiche> facade = new HibernateFacade<Affiche>();
		facade.createQuery(DELETES_AFFICHEID);
		facade.setParameterList("ids", ids);
		int c = facade.executeUpdate();
		return c;
	}
	
	public Affiche findById(int id) {
		Affiche item = null;
        HibernateFacade<Affiche> facade = new HibernateFacade<Affiche>(FIND_AFFICHEID);
        facade.setInt(0, id);
        facade.setCacheable(true); 
        facade.setMaxResults(1);
        item = (Affiche)facade.uniqueResult();
        return item;
	}

	public List<Affiche> findByParameter(AfficheParameter param) {
        List<Affiche> list = null;
        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");
		HibernateFacade<Affiche> facade = new HibernateFacade<Affiche>();
    	facade.createQuery(hql);
    	facade.setFirstResult(param.getPagination().getStartRow());
        facade.setMaxResults(param.getPagination().getEndRow());
        list = facade.executeQuery();  
		return list;
	}

	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");
		HibernateFacade facade = new HibernateFacade();
    	facade.createQuery(hql);
    	long c = facade.resultTotal();
		return c;
	}

	public List findAll(AfficheParameter param) {
		List list = null;
		HibernateFacade facade = new HibernateFacade();
    	facade.createQuery(FIND_ALL);
    	facade.setFirstResult(param.getPagination().getStartRow());
        facade.setMaxResults(param.getPagination().getEndRow());
        list = facade.executeQuery();  
		return list;
	}

	public long countAll(AfficheParameter param) {
		HibernateFacade facade = new HibernateFacade();
    	facade.createQuery(COUNT_ALL);
    	long c = facade.resultTotal();
		return c;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -