public void addRole(long orgId, long userId, ObjectRole role, List<Permission> permissions) {
   this.save(role);
   List<RolePermission> rolePermissions = this.getRolePermissions(role.getId());
   for (Permission p : permissions) {
     boolean found = false;
     for (RolePermission rp : rolePermissions) {
       if (rp.getPermissionId() == p.getId()) {
         found = true;
         break;
       }
     }
     if (!found) {
       RolePermission rp = new RolePermission(role.getId(), p.getId());
       this.save(rp);
     }
   }
 }
  public void updatePermission(long orgId, long userId, Permission permission) {
    String hql = "select perm from light_permission perm where id = " + permission.getId();
    Session session = this.getHibernateTemplate().getSessionFactory().openSession();
    Query query = session.createQuery(hql);
    Permission perm = (Permission) query.uniqueResult();
    session.close();

    perm.setDescription(permission.getDescription());
    perm.setName(permission.getName());

    this.save(perm);
  }