i'm using next code:
public static Object getLatestByConfigSpec(Mastered mastered, Iterated iterated) throws WTException
{
Object tempObject = null;
Object resultObject = null;
long id = 0;
QueryResult cQueryResult = ConfigHelper.service.filteredIterationsOf(mastered, ConfigHelper.service.getConfigSpecFor(iterated));
while(cQueryResult.hasMoreElements())
{
tempObject = cQueryResult.nextElement();
if(PersistenceHelper.getObjectIdentifier((Persistable) tempObject).getId() > id)
{
id = PersistenceHelper.getObjectIdentifier((Persistable) tempObject).getId();
resultObject = tempObject;
}
}
return resultObject;
}