query = createQuery("from edu.internet2.middleware.signet.AssignmentImpl" + " as assignment" + " where granteeKey  = :granteeKey" + " and functionKey   = :functionKey" + " and scopeID       = :scopeId" + " and scopeNodeID   = :scopeNodeId" + " and assignmentID != :assignmentId"); query.setParameter("granteeKey", assignment.getGrantee().getId(), Hibernate.INTEGER);
query = createQuery("from edu.internet2.middleware.signet.AssignmentImpl " + " as assignment " + " where granteeKey = :granteeKey " + " and functionKey = :functionKey " + " and scopeID = :scopeId " + " and scopeNodeID = :scopeNodeId " + " and assignmentID != :assignmentId "); query.setParameter("granteeKey", assignment.getGrantee().getSubject_PK(), Hibernate.LONG);
	public Set findDuplicates(Assignment assignment)	{		Query query;		List resultList;		try		{			query = createQuery("from edu.internet2.middleware.signet.AssignmentImpl" + " as assignment"					+ " where granteeKey  = :granteeKey" + " and functionKey   = :functionKey" + " and scopeID       = :scopeId"					+ " and scopeNodeID   = :scopeNodeId" + " and assignmentID != :assignmentId");			query.setParameter("granteeKey", assignment.getGrantee().getId(), Hibernate.INTEGER);			query.setParameter("functionKey", ((FunctionImpl)(assignment.getFunction())).getKey(), Hibernate.INTEGER);			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(signet);				// 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;	}