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

📄 recontentimpl.java

📁 这是一款最新的野蔷薇论坛源码,有需要的朋友可以尽情下载
💻 JAVA
字号:
/* 
 * Created on 2007-1-22
 * Last modified on 2007-1-22
 * Powered by YeQiangWei.com
 */
package com.yeqiangwei.club.dao.hibernate.impl;

import java.util.List;

import com.yeqiangwei.club.dao.ReContentDAO;
import com.yeqiangwei.club.dao.hibernate.support.HibernateFacade;
import com.yeqiangwei.club.dao.model.ReContent;
import com.yeqiangwei.club.param.TopicParameter;

public class ReContentImpl implements ReContentDAO {
	
	private static final String FIND_REPLYID = "from ReContent where replyId=?";
	
	private static final String FIND_RECONTENTID = "from ReContent where reContentId=?";
	
	private static final String DELETE_RECONTENTID = "delete from ReContent where reContentId=?";
	
	private static final String DELETES_RECONTENTID = "delete from ReContent where reContentId in (:ids)";

	private static final String DELETE_TOPICID = "delete from ReContent where topicId=?";
	
	private static final String DELETES_TOPICID = "delete from ReContent where topicId in (:ids)";

	private static final String DELETES_REPLYID = "delete from ReContent where replyId in (:ids)";
	
	public ReContent create(ReContent item) {
		HibernateFacade<ReContent> facade = new HibernateFacade<ReContent>();
		item = facade.save(item);		
		return item;
	}

	public ReContent update(ReContent item) {
        HibernateFacade<ReContent> facade = new HibernateFacade<ReContent>();
        item = facade.update(item);
        return item;
	}

	public int delete(ReContent item) {
        HibernateFacade<ReContent> facade = new HibernateFacade<ReContent>();
        facade.createQuery(DELETE_RECONTENTID);
        facade.setInt(0, item.getReContentId());
        int c = facade.executeUpdate();
		return c;
	}

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

	public int deleteByReplyId(List<Integer> ids) {
        HibernateFacade<ReContent> facade = new HibernateFacade<ReContent>();
        facade.createQuery(DELETES_REPLYID);
        facade.setParameterList("ids",ids);
        int c = facade.executeUpdate();
		return c;
	}
	
	public int deleteByTopicId(int topicId) {
        HibernateFacade<ReContent> facade = new HibernateFacade<ReContent>();
        facade.createQuery(DELETE_TOPICID);
        facade.setInt(0, topicId);
        int c = facade.executeUpdate();
		return c;
	}

	public int deleteByTopicId(List<Integer> ids) {
        HibernateFacade<ReContent> facade = new HibernateFacade<ReContent>();
        facade.createQuery(DELETES_TOPICID);
        facade.setParameterList("ids",ids);
        int c = facade.executeUpdate();
		return c;
	}

	public ReContent findById(int id) {
		ReContent item = null;
		HibernateFacade<ReContent> facade = new HibernateFacade<ReContent>();
        facade.createQuery(FIND_RECONTENTID);
        facade.setInt(0,id);
        facade.setMaxResults(1);
        item = facade.uniqueResult();
		return item;
	}
	
	public ReContent findByReplyId(int replyId) {
		ReContent item = null;
		HibernateFacade<ReContent> facade = new HibernateFacade<ReContent>();
        facade.createQuery(FIND_REPLYID);
        facade.setInt(0,replyId);
        facade.setMaxResults(1);
        item = facade.uniqueResult();
		return item;
	}

	public List<ReContent> findByParameter(TopicParameter param) {
		StringBuffer hql = new StringBuffer();
		hql.append("from ReContent where reContentId>0 ");
		if(param.getTopicId()!=null){
			hql.append(" and topicId=");
			hql.append(param.getTopicId());
		}
		if(param.getIsDeleted()!=null){
			hql.append(" and isDeleted=?");
		}
		/*
		if(param.getOrderBy()==null){
			hql.append(" order by replyId");
		}else{
			hql.append(" order by replyId");
		}
		*/
		hql.append(" order by replyId");
		HibernateFacade<ReContent> facade = new HibernateFacade<ReContent>();
		facade.createQuery(hql);
		if(param.getIsDeleted()!=null){
			facade.setBoolean(0, param.getIsDeleted().booleanValue());
		}
		facade.setFirstResult(param.getPagination().getStartRow());
		facade.setMaxResults(param.getPagination().getEndRow());
		List<ReContent> list = facade.executeQuery();
		return list;
	}

	public long countByParameter(TopicParameter param) {
		StringBuffer hql = new StringBuffer();
		hql.append("select count(reContentId) from ReContent where reContentId>0 ");
		if(param.getTopicId()!=null){
			hql.append(" and topicId=");
			hql.append(param.getTopicId());
		}
		if(param.getIsDeleted()!=null){
			hql.append(" and isDeleted=?");
		}
		HibernateFacade<ReContent> facade = new HibernateFacade<ReContent>();
		facade.createQuery(hql);
		if(param.getIsDeleted()!=null){
			facade.setBoolean(0, param.getIsDeleted().booleanValue());
		}
		facade.setCacheable(true);
		long c = facade.resultTotal();
		return c;
	}

	public List findAll(TopicParameter param) {
		return this.findByParameter(param);
	}

	public long countAll(TopicParameter param) {
		return this.countByParameter(param);
	}

}

⌨️ 快捷键说明

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