日期:2014-05-20 浏览次数:20748 次
public void roleRight(String[] rightCodes,String roleId){
Session session = HibernateSessionFactory.getSession();
SysRole role = dao.findRoleById(roleId);
role.setSysRights(null);
Set<SysRight> rights = new HashSet<SysRight>();
session.beginTransaction();
for (int i = 0; i < rightCodes.length; i++) {
SysRight right = dao.findRightById(rightCodes[i]);
rights.add(right);
}
role.setSysRights(rights);
session.saveOrUpdate(role);
session.getTransaction().commit();
HibernateSessionFactory.closeSession();
}