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

📄 groupimpl.java

📁 详细的建站源码 详细的建站源码 详细的建站源码 详细的建站源码
💻 JAVA
字号:
/* 
 * Created on 2007-2-23
 * Last modified on 2007-2-25
 * Powered by YeQiangWei.com
 */
package com.yeqiangwei.club.dao.hibernate.impl;

import java.util.List;

import com.yeqiangwei.club.dao.GroupDAO;
import com.yeqiangwei.club.dao.hibernate.support.HibernateFacade;
import com.yeqiangwei.club.dao.model.Group;
import com.yeqiangwei.club.param.GroupParameter;

public class GroupImpl implements GroupDAO {
	
	private static final String UPDATE_REGISTERDEFAULTNOID = "update com.yeqiangwei.club.dao.model.Group set registerDefault=? where groupId<>?";
	
	private static final String UPDATE_GUESTDEFAULTNOID = "update com.yeqiangwei.club.dao.model.Group set guestDefault=? where groupId<>?";
	
	private static final String FIND_GROUPID = "from com.yeqiangwei.club.dao.model.Group where groupId=?";
	
	private static final String DELETE_GROUPID = "delete from com.yeqiangwei.club.dao.model.Group where groupId=?";
	
	private static final String DELETES_GROUPID = "delete from com.yeqiangwei.club.dao.model.Group where groupId in (:ids)";
	
	private static final String FIND_GUESTDEFAULT = "from com.yeqiangwei.club.dao.model.Group where guestDefault=?";
	
	private static final String FIND_REGISTERDEFAULT = "from com.yeqiangwei.club.dao.model.Group where registerDefault=?";

	public Group create(Group item) {
		HibernateFacade<Group> facade = new HibernateFacade<Group>();
		item = facade.save(item);		
		return item;
	}

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

	public int delete(Group item) {
		HibernateFacade<Group> facade = new HibernateFacade<Group>();
		facade.createQuery(DELETE_GROUPID);
		facade.setInt(0, item.getGroupId());
		int c = facade.executeUpdate();
		return c;
	}

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

	public Group findById(int id) {
		Group item = null;
        HibernateFacade<Group> facade = new HibernateFacade<Group>();
        facade.createQuery(FIND_GROUPID);
        facade.setInt(0, id);
        facade.setCacheable(true); 
        facade.setMaxResults(1);
        item = (Group)facade.uniqueResult();
        return item;
	}

	public List<Group> findByParameter(GroupParameter param) {
		StringBuffer hql = new StringBuffer();
		hql.append("from Group order by groupId asc");
		List<Group> list = null;
		HibernateFacade<Group> facade = new HibernateFacade<Group>();
		facade.createQuery(hql.toString());
		list = facade.executeQuery();
		return list;
	}

	public long countByParameter(GroupParameter param) {
		StringBuffer hql = new StringBuffer();
		hql.append("select count(groupId) from Group ");
		HibernateFacade<Group> facade = new HibernateFacade<Group>();
    	facade.createQuery(hql);
		return facade.resultTotal();
	}

	public List findAll(GroupParameter param) {
		StringBuffer hql = new StringBuffer();
		hql.append("from Group");
		List list = null;
		HibernateFacade<Group> facade = new HibernateFacade<Group>();
    	facade.createQuery(hql);
        list = facade.executeQuery();  
		return list;
	}

	public long countAll(GroupParameter param) {
		StringBuffer hql = new StringBuffer();
		hql.append("select count(groupId) from Group ");
		HibernateFacade<Group> facade = new HibernateFacade<Group>();
    	facade.createQuery(hql);
		return facade.resultTotal();
	}

	public int updateRegisterDefaultNoId(int groupId, boolean registerDefault) {
		int c = 0;
		HibernateFacade<Group> facade = new HibernateFacade<Group>();
    	facade.createQuery(UPDATE_REGISTERDEFAULTNOID);
    	facade.setBoolean(0, registerDefault);
    	facade.setInt(1,groupId);
    	c = facade.executeUpdate();
		return c;
	}

	public int updateGuestDefaultNoId(int groupId, boolean guestDefault) {
		int c = 0;
		HibernateFacade<Group> facade = new HibernateFacade<Group>();
    	facade.createQuery(UPDATE_GUESTDEFAULTNOID);
    	facade.setBoolean(0, guestDefault);
    	facade.setInt(1,groupId);
    	c = facade.executeUpdate();
		return c;
	}

	public Group findByGuestDefault() {
		Group item = null;
        HibernateFacade<Group> facade = new HibernateFacade<Group>();
        facade.createQuery(FIND_GUESTDEFAULT);
        facade.setBoolean(0,true);
        facade.setCacheable(true); 
        facade.setMaxResults(1);
        item = (Group)facade.uniqueResult();
        return item;
	}

	public Group findByRegisterDefault() {
		Group item = null;
        HibernateFacade<Group> facade = new HibernateFacade<Group>();
        facade.createQuery(FIND_REGISTERDEFAULT);
        facade.setBoolean(0,true);
        facade.setCacheable(true); 
        facade.setMaxResults(1);
        item = (Group)facade.uniqueResult();
        return item;
	}
	
	/*
	public static void main(String args[]){
		com.yeqiangwei.club.dao.hibernate.ConnectionManager.init();
		GroupImpl i = new GroupImpl();
		i.updateGuestDefaultNoId(7,false);
	}
	*/
	
}

⌨️ 快捷键说明

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