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

📄 areaimpl.java

📁 野蔷薇论坛源码 java 自己看看吧。 学习用
💻 JAVA
字号:
/* 
 * Created on 2007-2-3
 * Last modified on 2007-11-3
 * Powered by YeQiangWei.com
 */
package com.yeqiangwei.club.dao.hibernate.impl;

import java.util.List;

import org.hibernate.HibernateException;

import com.yeqiangwei.club.dao.AreaDAO;
import com.yeqiangwei.club.dao.hibernate.support.HibernateFacade;
import com.yeqiangwei.club.dao.hibernate.support.HibernateProvider;
import com.yeqiangwei.club.dao.model.Area;
import com.yeqiangwei.club.exception.DAOException;
import com.yeqiangwei.club.param.AreaParameter;

public class AreaImpl implements AreaDAO {
	
	private static final String FIND_AREAID = "from Area where areaId=?";
	
	private static final String DELETE_AREAID = "delete from Area where areaId=?";
	
	private static final String DELETES_AREAID = "delete from Area where areaId in(:ids)";

	public void create(Area item) throws DAOException {
		HibernateProvider<Area> facade = new HibernateFacade<Area>();
		try{
			facade.save(item);
		}catch(HibernateException e){
			throw new DAOException(e);
		}
	}

	public void update(Area item) throws DAOException {
		HibernateProvider<Area> facade = new HibernateFacade<Area>();
		try{
			facade.update(item);
		}catch(HibernateException e){
			throw new DAOException(e);
		}
	}

	public int delete(Area item) throws DAOException {
    	HibernateProvider<Area> facade = new HibernateFacade<Area>();
		facade.createQuery(DELETE_AREAID);
		facade.setInt(0, item.getAreaId());
		try{
			return facade.executeUpdate();
		}catch(HibernateException e){
			throw new DAOException(e);
		}
	}

	public int delete(List<Integer> ids) throws DAOException {
    	HibernateProvider<Area> facade = new HibernateFacade<Area>();
		facade.createQuery(DELETES_AREAID);
		facade.setParameterList("ids",ids);
		try{
			return facade.executeUpdate();
		}catch(HibernateException e){
			throw new DAOException(e);
		}
	}

	public Area findById(int id) {
    	HibernateProvider<Area> facade = new HibernateFacade<Area>();
		facade.createQuery(FIND_AREAID);
		facade.setInt(0, id);
		return facade.uniqueResult();
	}

	public List<Area> findByParameter(AreaParameter param) {
		StringBuffer hql = new StringBuffer();
		hql.append("from Area order by orderList desc, areaId");
    	HibernateProvider<Area> facade = new HibernateFacade<Area>();
		facade.createQuery(hql);
		facade.setFirstResult(param.getPagination().getStartRow());
		facade.setMaxResults(param.getPagination().getEndRow());
		return facade.executeQuery();
	}

	public long countByParameter(AreaParameter param) {
		StringBuffer hql = new StringBuffer();
		hql.append("select count(areaId) from Area");
    	HibernateProvider<Area> facade = new HibernateFacade<Area>();
		facade.createQuery(hql);
		return facade.resultTotal();
	}

	public List<Area> findAll(AreaParameter param) {
		StringBuffer hql = new StringBuffer();
		hql.append("from Area order by orderList desc, areaId");
    	HibernateProvider<Area> facade = new HibernateFacade<Area>();
		facade.createQuery(hql);
		facade.setFirstResult(param.getPagination().getStartRow());
		facade.setMaxResults(param.getPagination().getEndRow());
		return facade.executeQuery();
	}

	public long countAll(AreaParameter param) {
		StringBuffer hql = new StringBuffer();
		hql.append("select count(areaId) from Area");
    	HibernateProvider<Area> facade = new HibernateFacade<Area>();
		facade.createQuery(hql);
		return facade.resultTotal();
	}

}

⌨️ 快捷键说明

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