forumlabelimpl.java

来自「社区文章采用的是平板、树形自由选择的两种展示方式」· Java 代码 · 共 85 行

JAVA
85
字号
/* 
 * Created on 2007-5-21
 * 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.ForumLabelDAO;
import com.yeqiangwei.club.dao.hibernate.support.HibernateFacade;
import com.yeqiangwei.club.dao.hibernate.support.HibernateProvider;
import com.yeqiangwei.club.model.ForumLabel;
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) {
		HibernateProvider<ForumLabel> facade = new HibernateFacade<ForumLabel>();
		facade.createQuery(UPDATE_FORUMID);
		facade.setInt(0, toForumId);
		facade.setInt(1, forumId);
		return facade.executeUpdate();
	}

	
	public void create(ForumLabel item) {
		HibernateProvider<ForumLabel> facade = new HibernateFacade<ForumLabel>();
		facade.save(item);
	}

	public void update(ForumLabel item) {
		HibernateProvider<ForumLabel> facade = new HibernateFacade<ForumLabel>();
		facade.update(item);
	}

	public int delete(ForumLabel item) {
    	HibernateProvider<ForumLabel> facade = new HibernateFacade<ForumLabel>();
		facade.createQuery(DELETE_LABELID);
		facade.setInt(0, item.getLabelId());
		return facade.executeUpdate();
	}

	public int delete(List<Integer> ids) {
    	HibernateProvider<ForumLabel> facade = new HibernateFacade<ForumLabel>();
		facade.createQuery(DELETE_LABELIDS);
		facade.setParameterList("ids",ids);
		return facade.executeUpdate();
	}

	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 + =
减小字号Ctrl + -
显示快捷键?