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

📄 forumlabelimpl.java

📁 野蔷薇论坛源码 java 自己看看吧。 学习用
💻 JAVA
字号:
/* 
 * Created on 2007-5-21
 * 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.ForumLabelDAO;
import com.yeqiangwei.club.dao.hibernate.support.HibernateFacade;
import com.yeqiangwei.club.dao.hibernate.support.HibernateProvider;
import com.yeqiangwei.club.dao.model.ForumLabel;
import com.yeqiangwei.club.exception.DAOException;
import com.yeqiangwei.club.param.ForumParameter;

public class ForumLabelImpl implements ForumLabelDAO{
	
	private static final String DELETE_LABELID = "delete from ForumLabel where labelId=?";
	
	private static final String DELETE_LABELIDS = "delete from ForumLabel where labelId in (:ids)";
	
	private static final String FIND_LABELID = "from ForumLabel where labelId=?";

	private static final String UPDATE_FORUMID = "update ForumLabel set forumId=? where forumId=?";

	@Override
	public int update(int forumId, int toForumId) throws DAOException {
		HibernateProvider<ForumLabel> facade = new HibernateFacade<ForumLabel>();
		facade.createQuery(UPDATE_FORUMID);
		facade.setInt(0, toForumId);
		facade.setInt(1, forumId);
		try{
			return facade.executeUpdate();
		}catch(HibernateException e){
			throw new DAOException(e);
		}
	}

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

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

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

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

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

	public List<ForumLabel> findByParameter(ForumParameter param) {
		StringBuffer hql = new StringBuffer();
		hql.append("from ForumLabel where labelId>0");
		if(param.getForumId()!=null){
			hql.append(" and forumId=");
			hql.append(param.getForumId().intValue());
		}
		hql.append(" order by orderList desc");
		HibernateProvider<ForumLabel> facade = new HibernateFacade<ForumLabel>();
		facade.createQuery(hql);
		return facade.executeQuery();
	}


	public long countByParameter(ForumParameter param) {
		return 0;
	}

}

⌨️ 快捷键说明

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