Skip to content

Commit

Permalink
Remove 'cross join' from count query. Updates "countHandlesByPrefix" …
Browse files Browse the repository at this point in the history
…to use a query similar to existing "findByPrefix"

(cherry picked from commit 14223bd)
  • Loading branch information
tdonohue authored and github-actions[bot] committed Sep 15, 2023
1 parent 4dedb3c commit e757b9d
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ public List<Handle> findByPrefix(Context context, String prefix) throws SQLExcep

@Override
public long countHandlesByPrefix(Context context, String prefix) throws SQLException {


CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
CriteriaQuery<Long> criteriaQuery = criteriaBuilder.createQuery(Long.class);
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Handle.class);

Root<Handle> handleRoot = criteriaQuery.from(Handle.class);
criteriaQuery.select(criteriaBuilder.count(criteriaQuery.from(Handle.class)));
criteriaQuery.select(handleRoot);
criteriaQuery.where(criteriaBuilder.like(handleRoot.get(Handle_.handle), prefix + "%"));
return countLong(context, criteriaQuery, criteriaBuilder, handleRoot);
}
Expand Down

0 comments on commit e757b9d

Please sign in to comment.