query.setString ("functionId", assignment.getFunction().getId()); query.setString ("subsystemId", assignment.getFunction().getSubsystem().getId());
query.setParameter ("functionKey", ((FunctionImpl)(assignment.getFunction())).getKey(), Hibernate.INTEGER);
  Set findDuplicates(Assignment assignment)  {    Query query;    List resultList;    try    {      query = session         .createQuery           ("from edu.internet2.middleware.signet.AssignmentImpl"            + " as assignment"            + " where granteeKey = :granteeKey"            + " and functionID = :functionId"            + " and subsystemID = :subsystemId"            + " and scopeID = :scopeId"            + " and scopeNodeID = :scopeNodeId"            + " and assignmentID != :assignmentId");      query.setParameter        ("granteeKey", assignment.getGrantee().getId(), Hibernate.INTEGER);      query.setString        ("functionId", assignment.getFunction().getId());      query.setString        ("subsystemId", assignment.getFunction().getSubsystem().getId());      query.setString        ("scopeId", assignment.getScope().getTree().getId());      query.setString        ("scopeNodeId", assignment.getScope().getId());            query.setParameter("assignmentId", assignment.getId(), Hibernate.INTEGER);      resultList = query.list();    }    catch (HibernateException e)    {      throw new SignetRuntimeException(e);    }    Set resultSet = new HashSet(resultList);    Set editedSet = new HashSet();    editedSet.addAll(resultSet);    Iterator resultSetIterator = resultSet.iterator();    while (resultSetIterator.hasNext())    {      Assignment matchedAssignment = (Assignment) (resultSetIterator.next());            if (matchedAssignment.getStatus() == Status.INACTIVE)      {        // We don't consider inactive Assignments when hunting for duplicates.        editedSet.remove(matchedAssignment);      }      else      {        ((AssignmentImpl) matchedAssignment).setSignet(this);        // Now, let's trim this set of Assignments down further, keeping only        // those Assignments whose LimitValues actually match.             if (!(assignment.getLimitValues()             .equals(matchedAssignment.getLimitValues())))        {          editedSet.remove(matchedAssignment);        }      }    }    return editedSet;  }