mships.addAll(l);
Iterator iter = l.iterator(); while (iter.hasNext()) { Membership ms = (Membership) iter.next(); ms.setSession(s); mships.add(ms); }
  protected static Set findMemberships(    GrouperSession s, Member m, Field f  )  {    /*     * @caller    public GrouperAccessAdapter.getGroupsWhereSubjectHasPriv(s, subj, priv)     * @caller    public GrouperNamingAdapter.getStemsWhereSubjectHasPriv(s, subj, priv)     * @caller    public Member.getMemberships(f)     * @filtered  true     * @session   true     */    GrouperSession.validate(s);    GrouperLog.debug(LOG, s, MSG_FMSHIPSM_PRO);    Set mships  = new LinkedHashSet();    try {      Session hs  = HibernateHelper.getSession();      List    l   = hs.find(        "from Membership as ms where  "        + "ms.member_id       = ?     "        + "and ms.field.name  = ?     "         + "and ms.field.type  = ?     ",        new Object[] {          m.getId(), f.getName(), f.getType().toString()        },        new Type[] {          Hibernate.STRING, Hibernate.STRING, Hibernate.STRING        }      );      Member all = MemberFinder.findAllMember();      l.addAll(         hs.find(          "from Membership as ms where  "          + "ms.member_id       = ?     "          + "and ms.field.name  = ?     "           + "and ms.field.type  = ?     ",          new Object[] {            all.getId(), f.getName(), f.getType().toString()          },          new Type[] {            Hibernate.STRING, Hibernate.STRING, Hibernate.STRING          }        )      );      hs.close();      GrouperLog.debug(LOG, s, MSG_FMSHIPSM_PRO + " unfiltered: " + l.size());      // If the session's member is equivalent to the member that we      // are searching for, don't filter the results, otherwise a      // member that has OPTIN, OPTOUT, etc will have those results      // filtered out.      if (s.getMember().equals(m)) {        mships.addAll(l);      }      else {        mships.addAll( _filterMemberships(s, f, l) );      }    }    catch (HibernateException eH) {      GrouperLog.error(LOG, s, MSG_FMSHIPSM_PRO + ": " + eH.getMessage());    }    GrouperLog.debug(LOG, s, MSG_FMSHIPSM_PRO + " filtered: " + mships.size());    return mships;  } // protected static Set findMemberships(s, m, f)