continue;
}
}
// Find out if the sort key includes the primary key
Key pk = getObjectKey();
boolean bMatch = false;
boolean bAscending = true;
for (int i = 0, k = -1; i < sortKey.getAttributeCount(); i++)
{
Attribute attr = sortKey.getAttribute(i);
if (attr == null)
{
bMatch = true;
bAscending = sortKey.isAscending(i);
break;
}
if (optionalSet != null && optionalSet.get(attr.getOrdinal()))
{
continue;
}
if (getAttributeMapping(attr) instanceof VirtualPrimitiveMapping)
{
VirtualPrimitiveMapping mapping = (VirtualPrimitiveMapping)getAttributeMapping(attr);
if (mapping.getObjectKeyPart() >= 0)
{
if (k == -1)
{
if (mapping.getObjectKeyPart() == 0)
{
k = 1;
bAscending = sortKey.isAscending(i);
continue;
}
break;
}
if (mapping.getObjectKeyPart() == k)
{
if ((pk.isPartAscending(0) ^ pk.isPartAscending(k)) != (bAscending ^ sortKey.isAscending(i)))
{
break;
}
else
{
if (k == pk.getPartCount() - 1)
{
bMatch = true;
break;
}
}
}
else
{
break;
}
}
}
}
Pair key = null;
// If the above is true, then append the primary key
// at the end of the sort key
if (bMatch)
{
Pair[] objKeyAttributeArray = new Pair[pk.getPartCount()];
for (int i = 0; i < m_metaclass.getInstanceAttributeCount(); i++)
{
Attribute attr = m_metaclass.getInstanceAttribute(i);
if (getAttributeMapping(attr) instanceof VirtualPrimitiveMapping)
{
VirtualPrimitiveMapping mapping = (VirtualPrimitiveMapping)getAttributeMapping(attr);
if (mapping.getObjectKeyPart() >= 0)
{
objKeyAttributeArray[mapping.getObjectKeyPart()] = new Pair(
attr.getSymbol(),
Boolean.valueOf(bAscending ^ !pk.isPartAscending(mapping.getObjectKeyPart()))
);
}
}
}