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

📄 usergroupdao.java

📁 一个关于物流的管理系统
💻 JAVA
字号:
package com.shunshi.ssh.dao;

import java.util.*;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.shunshi.ssh.entity.*;

public class UserGroupDAO extends HibernateDaoSupport implements IUserGroupDAO {

	public void save(UserGroup userGroup) {
		try {
			getHibernateTemplate().saveOrUpdate(userGroup);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void delete(UserGroup userGroup) {
		try {
			getHibernateTemplate().delete(userGroup);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public UserGroup findById(int id) {
		try {
			UserGroup userGroup = (UserGroup) getHibernateTemplate().get(
					"com.shunshi.ssh.entity.UserGroup", id);
			return userGroup;
		} catch (RuntimeException re) {
			throw re;
		}
	}
	
	public UserGroup findByUserGroupName(String userGroupName) {
		UserGroup userGroup=null;
		try {
			String sql="from UserGroup userGroup where groupName=?";
			List list=getHibernateTemplate().find(sql, userGroupName);
			if(list!=null && list.size()>0){
				 userGroup=(UserGroup)list.get(0);
			}
		} catch (RuntimeException re) {
			throw re;
		}
		return userGroup;
	}


	public Collection findByProperty(String propertyName, Object value) {
		try {
			String queryString = "from UserGroup as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Collection findAll() {
		try {
			String queryString = "from UserGroup";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void update(UserGroup userGroup) {
		try {
			getHibernateTemplate().saveOrUpdate(userGroup);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Collection queryPermissionsById(int id) {
		Collection permissionNames=new HashSet();
		UserGroup userGroup=null;
		try {
			String sql="from UserGroup userGroup where id=?";
			List list=getHibernateTemplate().find(sql, id);
			if(list!=null && list.size()>0){
				 userGroup= (UserGroup)list.get(0);
			}
			Set permissions=userGroup.getPermissions();
			Iterator iter=permissions.iterator();
			while(iter.hasNext()){
				Permission per=(Permission)iter.next();
				permissionNames.add(per.getName());
			}
		} catch (RuntimeException re) {
			throw re;
		}
		return permissionNames;
	}
}

⌨️ 快捷键说明

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