Skip to content
Snippets Groups Projects
Commit f320de55 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#400 - oder transactions with same date by id (equals creation order)

parent 23329d3e
No related branches found
No related tags found
No related merge requests found
......@@ -122,7 +122,7 @@ public class TransactionSpecifications
transferPredicates.add(nameLike);
}
query.orderBy(builder.desc(transaction.get(Transaction_.date)), builder.asc(transaction.get(Transaction_.name)));
query.orderBy(builder.desc(transaction.get(Transaction_.date)), builder.desc(transaction.get(Transaction_.ID)));
final Predicate predicatesCombined = combinePredicates(predicates, builder);
Predicate generalPredicates = builder.and(dateConstraint, predicatesCombined);
......
......@@ -474,4 +474,18 @@ class TransactionSpecificationsTest
.contains(transferTransaction)
.contains(transferTransactionWrongAccount);
}
@Test
void checkOrder()
{
Specification spec = TransactionSpecifications.withDynamicQuery(startDate, LocalDate.now(), account, true, true, true, null, List.of(), List.of(), null);
List<Transaction> results = transactionRepository.findAll(spec);
assertThat(results).hasSize(5)
.containsExactly(transaction3,
transaction2,
transferTransaction,
transaction1,
repeatingTransaction);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment