* @see nexj.core.persistence.PersistenceAdapter#isUnique(nexj.core.persistence.Query, java.util.List)
*/
public boolean isUnique(Query query, List sourceList)
{
int nCount = sourceList.size();
Set columnSet = new HashHolder(nCount);
for (int nSource = 0; nSource < nCount; ++nSource)
{
Source source = (Source)sourceList.get(nSource);
if (source instanceof Field)
{
addColumns((Field)source, columnSet);
}
else
{
Query assoc = source.getQuery();
if (assoc.getParent() == query)
{
Index index = (Index)query.getKey(false);
for (int i = 0, n = index.getIndexColumnCount(); i < n; ++i)
{
columnSet.add(index.getIndexColumn(i).getColumn());
}
}
}
}
if (!columnSet.isEmpty())
{
Set tableSet = new HashHolder(columnSet.size() >> 2);
for (Iterator itr = columnSet.iterator(); itr.hasNext();)
{
tableSet.add(((Column)itr.next()).getTable());
}
for (Iterator itr = tableSet.iterator(); itr.hasNext();)
{
Table table = (Table)itr.next();
loop:
for (int nIndex = 0, nIndexCount = table.getIndexCount(); nIndex < nIndexCount; ++nIndex)