Changed search query to also exact match primary key

This commit is contained in:
Francesco 2023-10-10 21:39:51 +02:00
parent c17d80514a
commit 3ee6497d09

View File

@ -87,11 +87,13 @@ public class CustomJpaRepository extends SimpleJpaRepository {
query.select(root) query.select(root)
.where( .where(
cb.and( cb.or(
finalPredicates.toArray(new Predicate[finalPredicates.size()]) // query search on String fields cb.and(finalPredicates.toArray(new Predicate[finalPredicates.size()])), // query search on String fields
cb.equal(root.get(schema.getPrimaryKey().getName()), q)
) )
); );
if (sortKey != null) if (sortKey != null)
query.orderBy(sortOrder.equals("DESC") ? cb.desc(root.get(sortKey)) : cb.asc(root.get(sortKey))); query.orderBy(sortOrder.equals("DESC") ? cb.desc(root.get(sortKey)) : cb.asc(root.get(sortKey)));