diff --git a/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java b/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java index e0153efa3..94bf5a5a1 100644 --- a/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java +++ b/src/main/java/org/alliancegenome/curation_api/dao/base/BaseSQLDAO.java @@ -667,10 +667,10 @@ public SearchResponse findByParams(Pagination pagination, Map if (orderByField != null) { query.orderBy(builder.asc(root.get(orderByField))); } else { - // Metamodel metaModel = entityManager.getMetamodel(); - // IdentifiableType of = (IdentifiableType) - // metaModel.managedType(myClass); - // query.orderBy(builder.asc(root.get(of.getId(of.getIdType().getJavaType()).getName()))); + // Else always order by the ID field to prevent random lists when using different page,limit combinations + Metamodel metaModel = entityManager.getMetamodel(); + IdentifiableType of = (IdentifiableType) metaModel.managedType(myClass); + query.orderBy(builder.asc(root.get(of.getId(of.getIdType().getJavaType()).getName()))); } if (queryOperator == Operator.AND) {