DbSess dbSess = new DbSess(); dbSess.txStart();
Grouper.dbSess().txStart();
  private List _saveChains(List vals) {    Map   cache       = new HashMap();    List  chainedVals = new ArrayList();    /*     * TODO Until we have a root session, we need a session to operate     *      within.     */    DbSess dbSess = new DbSess();     dbSess.txStart();    /*     * We need to step through the list values generated by memberOf     * and:     *  - Identify if the chain already exists     *  - Flesh out and save any newly discovered chains     *  - Attach the appropriate chainKey to each list value     *     * And, no, I'm not entirely sure if this is completely accurate.     */    Iterator valIter = vals.iterator();    while (valIter.hasNext()) {      GrouperList lv = (GrouperList) valIter.next();      String  chainKey  = null;      int     idx       = 0;      chainKey = MemberVia.findKey(s, lv.key(), lv.chain());      if (chainKey == null) {        if (cache.containsKey(lv.key())) {          chainKey = (String) cache.get(lv.key());          cache.put(lv.key(), chainKey);        } else {          chainKey = new GrouperUUID().toString();        }        Iterator chains = lv.chain().iterator();        while (chains.hasNext()) {          MemberVia mv = (MemberVia) chains.next();          mv.key(chainKey);          mv.idx(idx);          mv.save(dbSess);          idx++;        }       }      lv.chainKey(chainKey);      chainedVals.add( lv );    }    dbSess.txCommit();    dbSess.stop();    return chainedVals;  }