CLOUDSTACK-9006 - ListTemplates API returns result in inconsistent order when called concurrently

This commit is contained in:
ramamurtis 2015-10-30 09:44:59 +05:30
parent 1f6781babc
commit c90723f491
3 changed files with 3 additions and 1 deletions

View File

@ -89,7 +89,7 @@ public class Filter {
if (_orderBy == null) {
_orderBy = order.insert(0, " ORDER BY ").toString();
} else {
_orderBy = order.insert(0, _orderBy).toString();
_orderBy = order.insert(0, _orderBy + ", ").toString();
}
}

View File

@ -3106,6 +3106,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService, Confi
Boolean isAscending = Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm"));
isAscending = (isAscending == null ? Boolean.TRUE : isAscending);
Filter searchFilter = new Filter(TemplateJoinVO.class, "sortKey", isAscending, startIndex, pageSize);
searchFilter.addOrderBy(TemplateJoinVO.class, "tempZonePair", isAscending);
SearchBuilder<TemplateJoinVO> sb = _templateJoinDao.createSearchBuilder();
sb.select(null, Func.DISTINCT, sb.entity().getTempZonePair()); // select distinct (templateId, zoneId) pair

View File

@ -383,6 +383,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO, Long> im
Boolean isAscending = Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm"));
isAscending = (isAscending == null ? Boolean.TRUE : isAscending);
Filter searchFilter = new Filter(TemplateJoinVO.class, "sortKey", isAscending, null, null);
searchFilter.addOrderBy(TemplateJoinVO.class, "tempZonePair", isAscending);
List<TemplateJoinVO> uvList = new ArrayList<TemplateJoinVO>();
// query details by batches
int curr_index = 0;