@java.lang.SuppressWarnings({"rawtypes", "unchecked"})
public abstract class DynamicFinder
extends AbstractFinder
implements QueryBuildingFinder
Abstract base class for dynamic finders.
| Modifiers | Name | Description |
|---|---|---|
static java.lang.String |
ARGUMENT_CACHE |
|
static java.lang.String |
ARGUMENT_FETCH |
|
static java.lang.String |
ARGUMENT_FETCH_SIZE |
|
static java.lang.String |
ARGUMENT_FLUSH_MODE |
|
static java.lang.String |
ARGUMENT_IGNORE_CASE |
|
static java.lang.String |
ARGUMENT_LOCK |
|
static java.lang.String |
ARGUMENT_MAX |
|
static java.lang.String |
ARGUMENT_OFFSET |
|
static java.lang.String |
ARGUMENT_ORDER |
|
static java.lang.String |
ARGUMENT_READ_ONLY |
|
static java.lang.String |
ARGUMENT_SORT |
|
static java.lang.String |
ARGUMENT_TIMEOUT |
|
static java.lang.String |
ORDER_ASC |
|
static java.lang.String |
ORDER_DESC |
|
protected MappingContext |
mappingContext |
|
protected java.util.regex.Pattern |
pattern |
| Fields inherited from class | Fields |
|---|---|
class AbstractFinder |
datastore, datastoreResolver |
| Constructor and description |
|---|
protected DynamicFinder(java.util.regex.Pattern pattern, java.lang.String[] operators, DatastoreResolver datastoreResolver, MappingContext mappingContext) |
protected DynamicFinder(java.util.regex.Pattern pattern, java.lang.String[] operators, Datastore datastore) |
protected DynamicFinder(java.util.regex.Pattern pattern, java.lang.String[] operators, MappingContext mappingContext) |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static void |
applyDetachedCriteria(Query query, AbstractDetachedCriteria detachedCriteria)Applies the given detached criteria to the given query |
|
public static void |
applySortForMap(Query query, java.util.Map sortMap, boolean ignoreCase)Applies sorting logic to the given query from the given map |
|
public static MatchSpec |
buildMatchSpec(java.lang.String prefix, java.lang.String methodName, int parameterCount)Builds a match specification that can be used to establish information about a dynamic finder compilation for the purposes of compilation etc. |
|
public Query |
buildQuery(DynamicFinderInvocation invocation, Session session) |
|
protected void |
configureQueryWithArguments(java.lang.Class clazz, Query query, java.lang.Object[] arguments) |
|
public Criterion |
createCriterion() |
|
public DynamicFinderInvocation |
createFinderInvocation(java.lang.Class clazz, java.lang.String methodName, Closure additionalCriteria, java.lang.Object[] arguments) |
|
protected abstract java.lang.Object |
doInvokeInternal(DynamicFinderInvocation invocation) |
|
protected MethodExpression |
findMethodExpression(java.lang.Class clazz, java.lang.String expression) |
|
protected static MethodExpression |
findMethodExpression(java.lang.String expression) |
|
public boolean |
firstExpressionIsRequiredBoolean() |
|
public java.lang.Object[] |
getArguments() |
|
public int |
getArgumentsRequired() |
|
public static FetchType |
getFetchMode(java.lang.Object object)Retrieves the fetch mode for the specified instance; otherwise returns the default FetchMode. |
|
protected Junction |
getJunction(DynamicFinderInvocation invocation) |
|
public java.lang.Object |
invoke(java.lang.Class clazz, java.lang.String methodName, 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) |
|
public java.lang.Object |
invoke(java.lang.Class clazz, java.lang.String methodName, java.lang.Object[] arguments) |
|
public boolean |
isMethodMatch(java.lang.String methodName)Checks whether the given method is a match |
|
public static java.lang.String |
normalizeDirection(java.lang.String direction)Trims and accepts only asc or desc, case-insensitively. |
|
public static void |
populateArgumentsForCriteria(BuildableCriteria query, java.util.Map argMap)Populates arguments for the given query form the given map |
|
public static void |
populateArgumentsForCriteria(java.lang.Class<? extends java.lang.Object> targetClass, Query query, java.util.Map argMap) |
|
public static void |
registerNewMethodExpression(java.lang.Class methodExpression)Registers a new method expression. |
|
public void |
setArguments(java.lang.Object[] arguments) |
|
public void |
setPattern(java.lang.String pattern)Sets the pattern to use for this finder |
|
public static void |
validateSortProperty(PersistentEntity entity, java.lang.String sort)Rejects a sort key that is not shaped like a property path. |
| Methods inherited from class | Name |
|---|---|
class AbstractFinder |
applyAdditionalCriteria, execute, execute, getDatastore |
Applies the given detached criteria to the given query
query - The querydetachedCriteria - The detached criteriaApplies sorting logic to the given query from the given map
query - The querysortMap - The sort mapignoreCase - Whether toi ignore caseBuilds a match specification that can be used to establish information about a dynamic finder compilation for the purposes of compilation etc.
prefix - The dynamic finder prefix. For example 'findBy'methodName - The full method nameparameterCount - The number of parametersRetrieves the fetch mode for the specified instance; otherwise returns the default FetchMode.
object - The object, converted to a stringChecks whether the given method is a match
methodName - The method name Trims and accepts only asc or desc, case-insensitively. Blank and
null default to asc. The exception message omits the caller-supplied
value, which usually originates from request parameters.
Like validateSortProperty(PersistentEntity, String), this is shared by every entry
point that accepts an order argument, including listOrderBy* and criteria
queries, so a direction is never silently coerced on one path and rejected on another.
direction - the caller-supplied order argumentPopulates arguments for the given query form the given map
query - The queryargMap - The query argumentsRegisters a new method expression. The Class must extends from the class MethodExpression and provide a constructor that accepts a Class parameter and a String parameter.
methodExpression - A class that extends from MethodExpressionSets the pattern to use for this finder
pattern - A regular expression Rejects a sort key that is not shaped like a property path. When the entity is known and the
first segment names one of its persistent properties, every further segment must also resolve
through the mapping: associations and embedded components are traversed, and identity
properties, including the members of a composite identity, are recognised. A dotted key
whose first segment is not a persistent property is accepted on the shape check alone,
because criteria and where-query aliases such as c1.name are not persistent
properties; the underlying query implementation resolves them, or reports an unknown name,
itself. A bare name that is not a persistent property is rejected, since nothing else can be
sorted on by a single name.
This is the single check behind every entry point that accepts a caller-supplied
sort argument: list(), dynamic finders, where queries and criteria queries.
Query implementations that handle the argument themselves call it so that the same value
fails the same way everywhere.
The exception message deliberately omits the caller-supplied value: sort keys are commonly taken straight from request parameters.
entity - the entity being queried, or null when it cannot be resolvedsort - the requested sort property