public class PrefetchEvaluator extends MEXTransformerEvaluator
The Prefetch instruction allows for "Eager Loading" of object relationships (attribute chains). By specifying paths here, the underlying persistence handler can fetch related entities in a single database round-trip, avoiding the "N+1 selects" problem during result iteration.
Example usage:
"{Prefetch Orders, Orders.Items, Contacts}"
Note: Similar to Union operations, this evaluator returns an empty string
as its primary purpose is to modify the execution state of the MEXPersistenceQueryResults
context, not the query text itself.
| Constructor and Description |
|---|
PrefetchEvaluator(MEXPersistenceQueryResults _mexQR)
Constructs a new PrefetchEvaluator.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canHandle(java.lang.CharSequence s)
Determines if the expression is a Prefetch instruction.
|
java.lang.CharSequence |
evaluate(java.lang.CharSequence s,
MEXTransformer transformer)
Parses and evaluates the Prefetch instruction.
|
public PrefetchEvaluator(MEXPersistenceQueryResults _mexQR)
_mexQR - the MEX query results context where prefetch paths will be registered.public boolean canHandle(java.lang.CharSequence s)
canHandle in class MEXTransformerEvaluators - the expression string to check.true if it begins with "Prefetch".public java.lang.CharSequence evaluate(java.lang.CharSequence s,
MEXTransformer transformer)
The method strips the "Prefetch" tag, splits the remaining string by commas, validates each path, and registers it with the parent query context.
evaluate in interface MEXTransformerEvaluatorIevaluate in class MEXTransformerEvaluators - the instruction sequence (e.g. "Prefetch a, b.c").transformer - the active transformer.MEXUnavailableException - if a provided path is syntactically invalid
(e.g. contains illegal characters or empty segments).Copyright © 2000-2026 OAshi S.à r.l. All Rights Reserved.