Copilot commented on code in PR #16520:
URL: https://github.com/apache/grails-core/pull/16520#discussion_r4185448146
##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQuery.java:
##########
@@ -539,7 +546,7 @@ public Number countResults() {
countQuery.from(innerSubquery);
countQuery.select(cb.count(cb.literal(1)));
- result = (Number)
getHibernateQueryExecutor().singleResult(getCurrentSession(), countQuery,
creator.getParameterValues());
+ result = (Number)
getCountQueryExecutor().singleResult(getCurrentSession(), countQuery,
creator.getParameterValues());
Review Comment:
The same count-execution pattern is duplicated across both branches.
Consider extracting a small private helper (e.g.,
`executeCountSingleResult(query, params)`) to centralize how count queries are
run, making future changes (executor options, parameter handling) less
error-prone.
##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/query/HibernateQuery.java:
##########
@@ -526,7 +532,8 @@ public Number countResults() {
Number result;
if (projections.getProjectionList().isEmpty()) {
projections().count();
- result = (Number) executeSingleResult();
+ var creator = createJpaCriteriaQueryCreator();
+ result = (Number)
getCountQueryExecutor().singleResult(getCurrentSession(),
creator.createQuery(), creator.getParameterValues());
Review Comment:
The same count-execution pattern is duplicated across both branches.
Consider extracting a small private helper (e.g.,
`executeCountSingleResult(query, params)`) to centralize how count queries are
run, making future changes (executor options, parameter handling) less
error-prone.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]