jdaugherty commented on code in PR #15568:
URL: https://github.com/apache/grails-core/pull/15568#discussion_r3255000578


##########
grails-datamapping-core/src/main/groovy/grails/gorm/DetachedCriteria.groovy:
##########
@@ -514,24 +518,8 @@ class DetachedCriteria<T> extends 
AbstractDetachedCriteria<T> implements GormOpe
      * @return The count
      */
     Number count(Map args = Collections.emptyMap(), 
@DelegatesTo(DetachedCriteria) Closure additionalCriteria = null) {
-        if (!projections.isEmpty()) {
-            // When user-defined projections exist (e.g. groupProperty + 
count),
-            // a simple count() projection returns incorrect results because it
-            // appends to the existing projections rather than replacing them.
-            // Fall back to counting the grouped result rows.
-            // This will be resolved properly in Grails 8 with Hibernate 7's
-            // JpaSelectCriteria.from(Subquery) support for derived tables.
-            log.warn('DetachedCriteria.count() with user-defined projections 
cannot use a SQL count query ' +

Review Comment:
   Not a regression — the workaround was properly moved down into the Query 
abstraction layer. `AbstractHibernateQuery.countResults()` (H5) still checks 
`HibernateProjectionList`, emits the same warning, and falls back to 
`list().size()`. The base `Query.countResults()` does the same for other 
backends. `DetachedCriteria.count()` is now cleanly backend-agnostic.
   



-- 
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]

Reply via email to