public class CountFinder extends java.lang.Object implements FinderMethod, QueryBuildingFinder
Implements countBy*. Kept as its own dedicated class rather than a variant of SingleResultFinder: its buildQuery does not reuse DynamicFinder.getJunction at
all - for the Or operator it extends the query's own top-level junction directly via
Query.disjunction()/Query.add(Junction, Criterion), rather than building a
standalone Disjunction added as one nested criterion the way every other finder's
shared buildQuery does. This divergence is preserved exactly as it existed before this
class existed, not unified with the shared grammar's junction-building.
A trailing argument map is ignored, so max, offset, sort and
order never page or order the count. Callers can pass the same pagination parameters
to findAllBy* and countBy* and still get the total number of matches.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static Query |
applyCriteriaAndCount(DynamicFinderInvocation invocation, java.lang.Class<?> clazz, Query query)Applies this finder's independent (non-DynamicFinder.getJunction) And/Or criteria handling and the count() projection to an already-created query. |
|
public Query |
buildQuery(DynamicFinderInvocation invocation, Session session) |
|
public static CountFinder |
countBy(Datastore datastore) |
|
public static CountFinder |
countBy(DatastoreResolver datastoreResolver, MappingContext mappingContext) |
|
public static CountFinder |
countBy(MappingContext mappingContext) |
|
public java.lang.Object |
invoke(java.lang.Class clazz, java.lang.String methodName, java.lang.Object[] arguments) |
|
public java.lang.Object |
invoke(java.lang.Class clazz, java.lang.String methodName, groovy.lang.Closure additionalCriteria, java.lang.Object[] arguments) |
|
public java.lang.Object |
invoke(java.lang.Class clazz, java.lang.String methodName, DetachedCriteria detachedCriteria, java.lang.Object[] arguments)Not part of FinderMethod - called reflectively (dynamic Groovy dispatch) by AbstractDetachedCriteria.methodMissing. |
|
public boolean |
isMethodMatch(java.lang.String methodName) |
|
public void |
setPattern(java.lang.String pattern) |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |
Applies this finder's independent (non-DynamicFinder.getJunction) And/Or criteria
handling and the count() projection to an already-created query. Exposed as a public
static helper so other query-building strategies (e.g. grails-datamapping-rx's
count finder, which builds its query outside a Session) can reuse this logic rather
than duplicating it. The invocation's argument map is not applied to the query.
invocation - The invocationclazz - The persistent classquery - The already-created query to apply criteria toNot part of FinderMethod - called reflectively (dynamic Groovy dispatch) by AbstractDetachedCriteria.methodMissing. See SingleResultFinder.invoke for the full rationale.
clazz - The persistent classmethodName - The method namedetachedCriteria - The detached criteria to merge into the built queryarguments - The method call arguments