Skip to content

Commit

Permalink
Merge pull request #1636 from alliance-genome/release/v0.34.3
Browse files Browse the repository at this point in the history
Updated query to always have an orderBy
  • Loading branch information
oblodgett authored Aug 8, 2024
2 parents 5d6de03 + 66a7104 commit 91a1e51
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -667,10 +667,10 @@ public SearchResponse<E> findByParams(Pagination pagination, Map<String, Object>
if (orderByField != null) {
query.orderBy(builder.asc(root.get(orderByField)));
} else {
// Metamodel metaModel = entityManager.getMetamodel();
// IdentifiableType<E> of = (IdentifiableType<E>)
// 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<E> of = (IdentifiableType<E>) metaModel.managedType(myClass);
query.orderBy(builder.asc(root.get(of.getId(of.getIdType().getJavaType()).getName())));
}

if (queryOperator == Operator.AND) {
Expand Down

0 comments on commit 91a1e51

Please sign in to comment.