public class PreselectQuery extends AbstractQuery implements Joinable, RecordChangeListener, QueryConstants, Finalizable, SessionListener
Joinable interface, instances may be added as components of
a CompoundQuery.
The query is lazily executed the first time a record retrieval/navigation method is invoked. Only the database identifiers (i.e., primary keys) of the records are retrieved by the initial query. On each subsequent fetch, a row in this result list is retrieved, where each column contains the primary key for the record associated with the corresponding query component. The record for each primary key is retrieved and stored in its associated buffer.
At this time, outer joins are not supported. Furthermore, components may only specify NEXT as their iteration type at this time. FIRST and LAST currently are not supported.
When used to represent a Progress query (created with DEFINE or OPEN
QUERY), lenient-off-end must be enabled at construction. This mode
suppresses end condition exceptions for next and
previous commands which run off the end of the query's
results.
This query may be integrated with a client-side where clause expression,
by passing a non-null Supplier<logical> argument
to one of the single-table constructor variants. Note that additional
components may not be added to an instance so created, since this type of
query must act against no more than one record buffer. If a multi-table
preselect query is called for, CompoundQuery must be used,
though its components may be instances of this class.
| Modifier and Type | Class and Description |
|---|---|
private static class |
PreselectQuery.TemplateResults
Special
Results implementation for template records. |
P2JQuery.Parameter, P2JQuery.ParamResolver, P2JQuery.QueryEventListener, P2JQuery.QueryOpenedListenerSessionListener.Event, SessionListener.Scope| Modifier and Type | Field and Description |
|---|---|
protected boolean |
betweenRows
Has query been repositioned between result rows?
|
private Finalizable |
cleaner
Cleaner executed when this query's block is exit.
|
protected java.util.ArrayList<QueryComponent> |
components
Components of the query; at least 1 is required
|
protected boolean |
currentRowDeleted
Determines if the current row was deleted by DELETE-RESULT-LIST-ENTRY.
|
private java.util.List<java.lang.String> |
dynamicSorts
The list of sorting criteria added dynamically, at runtime.
|
private static java.util.ArrayList<SortCriterion> |
EMPTY_ARRAY
Empty array instance.
|
private boolean |
forceOnlyId
Force the query to retrieve only the ids
|
private java.lang.String |
fql
FQL query string to retrieve primary key ID arrays
|
private boolean |
fullRecords
Force query to retrieve full records, rather than primary keys only
|
private static CentralLogger |
LOG
Logger
|
private static boolean |
LOG_FINE
Test whether the log messages with FINE priority are allowed.
|
protected OffEnd |
offEnd
Has the query run off either end of its result set?
|
private Persistence |
persistence
Persistence object which this query's components use
|
private static NanoTimer |
QUERY_ASSEMBLE
Instrumentation for
assembleFQL(). |
private boolean |
regCleaner
Has query been registered for resource cleanup?
|
private boolean |
regWithSession
Is query registered for session event notification?
|
private RepositionCache |
repoCache
Cache of primary key lists to result set row numbers
|
private boolean |
resolvableArgs
Does this query have any arguments which are runtime resolvable?
|
private Results |
results
Result set for this query
|
private int |
rowCount
Number of total results returned
|
private boolean |
scrolling
Flag indicating results must be scrollable
|
protected java.lang.String |
sort
FQL order by clause used across all query components
|
protected boolean |
sortTranslated
Flag indicating if the
sort has been translated. |
private boolean |
thisFinalizable
Flag indicating that this instance was registered as a finalizable.
|
protected boolean |
unregisterOnCleanup
Determines if this will be unregistered from ChangeBroker on cleanup.
|
private java.util.List<java.util.function.Supplier<logical>> |
whereExprList
List of client-side where clause expressions
|
private boolean |
whereTranslated
Flag indicated if the WHERE clause has been translated.
|
closed, dynamicPredicate, errorHelper, excluded, included, indexedReposition, inverseSorting, lenientOffEnd, outer, parameterFilterCURRENT, FIRST, ITERATE, LAST, NEXT, NONE, PREVIOUS, RETRIEVE_MODES, UNIQUE| Constructor and Description |
|---|
PreselectQuery()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
_isOffEnd()
Indicate whether the query has run off either end of its result set,
due to scrolling beyond the last record or before the first record.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
DataModelObject inverse)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
DataModelObject inverse,
LockType lockType)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
DataModelObject inverse,
java.lang.Object[] args)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
DataModelObject inverse,
java.lang.Object[] args,
LockType lockType)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
DataModelObject inverse,
java.lang.Object[] args,
LockType lockType,
int iteration,
boolean outer)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
LockType lockType)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
java.lang.Object[] args)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
java.lang.Object[] args,
LockType lockType)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
java.lang.Object[] args,
LockType lockType,
int iteration,
boolean outer)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
java.lang.String indexInfo)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
java.lang.String indexInfo,
DataModelObject inverse)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
java.lang.String indexInfo,
DataModelObject inverse,
LockType lockType)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
java.lang.String indexInfo,
DataModelObject inverse,
java.lang.Object[] args)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
java.lang.String indexInfo,
DataModelObject inverse,
java.lang.Object[] args,
LockType lockType)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
java.lang.String indexInfo,
DataModelObject inverse,
java.lang.Object[] args,
LockType lockType,
int iteration,
boolean outer)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
java.lang.String indexInfo,
LockType lockType)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
java.lang.String indexInfo,
java.lang.Object[] args)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
java.lang.String indexInfo,
java.lang.Object[] args,
LockType lockType)
Add a component to the query.
|
void |
addComponent(DataModelObject dmo,
java.lang.String where,
java.lang.String indexInfo,
java.lang.Object[] args,
LockType lockType,
int iteration,
boolean outer)
Add a component to the query.
|
protected void |
addComponent(QueryComponent comp)
Add a component to the query.
|
boolean |
addDynamicFilter(FieldReference fr,
BaseDataType val,
java.lang.String format)
Adds a new constraint term to the where predicate of this query, effectively filtering out
any rows whose referenced field does not match the requested value.
|
(package private) void |
addDynamicSortCriterion(FieldReference fr,
boolean asc)
Adds a new sorting criterion as the strongest criterion for sorting the result of this
query.
|
P2JQuery |
addExternalBuffers(DataModelObject... dmos)
Add one or more buffers to the list of those which this query references externally.
|
void |
addWhereExpression(java.util.function.Supplier<logical> whereExpr)
Add a client-side where expression to this query.
|
protected boolean |
anyBoundBufferInComponent()
Check if any query component (added until the current call) has bound buffers.
|
private java.lang.String |
assembleFQL()
Assemble the FQL which is submitted to Hibernate in order to execute
the database query underlying this object.
|
private void |
assembleFQLImpl(java.lang.StringBuilder buf)
Assemble the FQL which is submitted to Hibernate in order to execute
the database query underlying this object.
|
protected FQLExpression |
assembleFromAndWhereClauses(java.util.ArrayList<SortCriterion> sortCriteria)
Assemble the from and the where clause for an FQL query.
|
protected java.util.ArrayList<SortCriterion> |
assembleOrderByClause()
Assemble the
order by clause for an FQL query. |
protected java.util.ArrayList<SortCriterion> |
assembleOrderByClause(java.util.List<SortCriterion> sortCriteria)
Assemble the
order by clause for an FQL query. |
protected java.util.List<SortCriterion> |
assembleOrderByClause(java.lang.String sort)
Assemble the
order by clause for an FQL query. |
protected void |
assembleSelectClause(java.lang.StringBuilder buf)
Assemble the select clause for an FQL projection query, where the only
field retrieved for each buffer is the primary key.
|
protected void |
assembleWhereClause(java.util.ArrayList<SortCriterion> sortCriteria,
int indices,
FQLExpression whereClause,
FQLExpression onClause,
boolean isOn)
Assemble the restriction (i.e., where) clause for an FQL query.
|
boolean |
backward(int rows)
Move the current cursor position backward by the specified number of rows.
|
boolean |
backward(NumberType rows)
Move the current cursor position backward by the specified number of rows.
|
protected java.util.ArrayList<SortCriterion> |
buildSortCriteria(java.lang.String sort)
Returns a list
SortCriterion objects build from the given sort clause. |
protected Results |
cacheResults(Results target)
Attempt to cache all results from the specified target result set into a
Results
instance. |
void |
cleanup()
Clean up query resources when this query's scope ends.
|
void |
clearDynamicFilters()
Clears any dynamically filters added at runtime.
|
(package private) void |
clearDynamicSortCriteria()
Clears any dynamically sort criteria added at runtime.
|
protected void |
clearRepoCache()
Clear the reposition cache of visited, virtual composite rows.
|
void |
close()
Explicitly close the query.
|
void |
close(boolean inResource)
Explicitly close the prepared query.
|
protected java.util.ArrayList<QueryComponent> |
components()
Get the query components.
|
protected boolean |
coreFetch(java.lang.Object[] data,
LockType lockType,
boolean errorIfNull,
boolean silentIfNullId)
Fetch all records for a given result row into their backing buffers, given an array of data which
contains one primary key or DMO per query component.
|
logical |
createResultListEntry()
Creates an entry in the result list for the current row.
|
protected Results |
createResults(Results results)
Optionally wrapper the result set created for the query with a filtering
Results implementation (for client-side where processing). |
boolean |
current()
Reload the current composite row of results for the query.
|
boolean |
current(LockType lockType)
Reload the current composite row of results for the query, overriding
the lock type to apply to each record.
|
integer |
currentRow()
Progress-compatible function that returns the 1-based index of the
current row in the result set.
|
integer |
currentRowImpl()
Get the 1-based index of the current row in the result set.
|
void |
deleted()
Provides a notification that the external program scope in which the object is registered is
is being deleted and the object's reference will be lost after this method is called.
|
logical |
deleteResultListEntry(boolean allowBetweenRows)
Deletes the current row of a query's result list.
|
void |
deregisteredSessionListener()
Invoked when this session listener is removed from the list of
registered session listeners.
|
protected boolean |
execute()
Compose an FQL query statement to represent the combination of all query
components, execute it, and store the scrollable results.
|
protected Results |
executeQuery(Persistence persistence,
java.lang.String fql,
java.lang.Object[] args)
Execute the query to create a first level result set.
|
protected <T> ScrollableResults<T> |
executeScroll(Persistence persistence,
java.lang.String fql,
java.lang.Object[] args)
Execute the query to create a
ScrollableResults result set. |
protected void |
fetch(boolean available,
LockType lockType,
boolean errorIfNull)
Fetch all records for a given result row into their backing buffers.
|
private QueryComponent |
findComponent(RecordBuffer buffer)
Find the query component associated with the given record buffer.
|
void |
finished()
Provides a notification that the scope in which this query was created
is ending.
|
boolean |
first()
Retrieve the first composite row of results for the query.
|
boolean |
first(LockType lockType)
Retrieve the first composite row of results for the query.
|
void |
forceDynamicOperation()
Force this query to operate in dynamic retrieval mode, if it supports this mode.
|
boolean |
forward(int rows)
Advance the current cursor position forward by the specified number of rows.
|
boolean |
forward(NumberType rows)
Advance the current cursor position forward by the specified number of rows.
|
private void |
generateOrderBy(java.util.ArrayList<SortCriterion> sortCriteria,
java.lang.StringBuilder buf)
Generates the
order by clause starting from the list of criteria, including the "order by"
keyword. |
java.lang.Object[] |
getArgs()
Get the query substitution arguments associated with this query, if any.
|
protected java.lang.String[] |
getEntities()
Collect the names of the entities (DMO types) associated with this query.
|
RecordBuffer[] |
getExternalBuffers()
Get the external buffers, if any, associated with this query.
|
protected java.lang.String |
getHQL()
Get the FQL query which was executed to produce this query's results.
|
AbstractJoin |
getJoin()
Get the legacy natural join, if any, associated with this query.
|
OffEnd |
getOffEnd()
Get the off-end status of this query, which indicates whether the query
has run off either end of its results.
|
java.util.ArrayList<QueryOffEndListener> |
getOffEndListeners()
Get all the off-end listeners associated with this query.
|
java.lang.String |
getOriginalWhere()
Get the original, FQL where clause associated with this query.
|
protected Persistence |
getPersistence()
Get the persistence service object used by this query.
|
RecordBuffer[] |
getRecordBuffers()
Access the record buffers manipulated by this query, in order from
left-most (outermost) table of the query's join (if any) to right-most
(innermost) table.
|
protected Results |
getResults()
Access the current
Results object for this query. |
java.lang.Object[] |
getRow()
Assemble an array of primary key IDs for the current record(s) in the
buffers underlying this query, from left-most to right-most (in the
sense of how the query joins the associated tables).
|
java.lang.String |
getSortPhrase()
Get the sort phrase associated with this query.
|
int |
getTableCount()
Get the number of tables joined by this query.
|
protected java.lang.Long |
getTemplateQueryRowid(java.lang.Object[] args)
Checks if this is a template query.
|
protected java.util.List<java.util.function.Supplier<logical>> |
getWhereExpressions()
Get this query's client-side where expressions.
|
protected void |
handleMissingJoinRecord()
Respond to the condition that a component with a non-null JOIN has a
missing inverse on which to perform the join.
|
boolean |
hasWhereExpression()
Indicate whether this query has a client-side where clause expression associated with it.
|
character |
indexInformation(NumberType n)
Conversion of INDEX-INFORMATION attribute (KW_IDX_INFO).
|
PreselectQuery |
initialize(boolean lenientOffEnd,
java.lang.String sort)
Initializer logic which is typically used for a multi-table query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
DataModelObject inverse)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
DataModelObject inverse,
LockType lockType)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
DataModelObject inverse,
java.lang.Object[] args)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
DataModelObject inverse,
java.lang.Object[] args,
LockType lockType)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
LockType lockType)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
java.lang.Object[] args)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
java.lang.Object[] args,
LockType lockType)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
java.lang.String indexInfo)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
java.lang.String indexInfo,
DataModelObject inverse)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
java.lang.String indexInfo,
DataModelObject inverse,
LockType lockType)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
java.lang.String indexInfo,
DataModelObject inverse,
java.lang.Object[] args)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
java.lang.String indexInfo,
DataModelObject inverse,
java.lang.Object[] args,
LockType lockType)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
java.lang.String indexInfo,
LockType lockType)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
java.lang.String indexInfo,
java.lang.Object[] args)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
java.lang.String indexInfo,
java.lang.Object[] args,
LockType lockType)
Initializer logic designed for a single-table preselect query.
|
PreselectQuery |
initialize(java.lang.String sort)
Initializer logic which is typically used for a multi-table query.
|
protected boolean |
isClientWhere()
Indicate whether this query requires initial results to be filtered
through a client-side where clause expression.
|
boolean |
isFullRecords()
Indicate whether the query will retrieve full records, rather than primary keys only.
|
protected boolean |
isLenientOffEnd()
Indicate whether this query will throw a
QueryOffEndException when it runs off the end of its
results. |
boolean |
isNativelyPreselect()
Indicate whether this query is a preselect query by its nature.
|
protected boolean |
isNativelyScrolling()
Indicate whether this query type is scrolling by its nature.
|
private boolean |
isOrderByRequired()
Function for deciding whether the ORDER BY clause is required in the FQL.
|
boolean |
isPreselect()
Indicate whether this query preselects all of its results.
|
private boolean |
isResultSetCached()
Indicate whether the full result set for this query has been cached.
|
boolean |
isScrolling()
Indicate whether this query's
scrolling flag has been set. |
protected boolean |
isTopLevelCleanup()
Indicate whether results resources should be cleaned up upon exiting
the global scope or upon exiting the nearest enclosing scope in which
the results were created.
|
void |
iterate()
Provides a notification that the block whose scope in which the object
is registered is about to iterate and attempt another pass.
|
boolean |
last()
Retrieve the last composite row of results for the query.
|
boolean |
last(LockType lockType)
Retrieve the last composite row of results for the query.
|
void |
load(java.lang.Object[] data,
LockType lockType,
boolean silentIfNullId)
Load one or more records into their associated buffers, given an array of primary key ID values, or the
actual DMOs themselves.
|
AdaptiveComponent |
makeAdaptiveServerJoinComponent(java.util.List<AdaptiveComponent> joinList,
AdaptiveQuery query,
int iteration,
boolean outer,
CompoundComponent fallback)
Create an adaptive query component based on the information in this query (which is
presumed to be a single-table query), and given a list of adaptive query components which
represent outer, nested query loops, which will perform a server-side join to the
innermost, nested query component.
|
QueryComponent |
makePreselectServerJoinComponent(java.util.List<QueryComponent> joinList,
int iteration,
boolean outer)
Create a preselect query component based on the information in this query (which is
presumed to be a single-table query), and given a list of preselect query components which
represent outer, nested query loops, which will perform a server-side join to the
innermost, nested query component.
|
boolean |
next()
Retrieve the next composite row of results for the query.
|
boolean |
next(LockType lockType)
Retrieve the next composite row of results for the query.
|
void |
open()
Open the prepared query and reposition it to the first result if the query is being browsed.
|
java.lang.Object[] |
peekFirst()
Fetch the array of primary key IDs associated with the first result in
this query's result list.
|
java.lang.Object[] |
peekLast()
Fetch the array of primary key IDs associated with the last result in
this query's result list.
|
java.lang.Object[] |
peekNext()
Fetch the array of primary key IDs associated with the next result in
this query's result list.
|
java.lang.Object[] |
peekPrevious()
Fetch the array of primary key IDs associated with the previous result
in this query's result list.
|
protected void |
prepareParameters(java.util.List<java.lang.Object> args)
Prepare query substitution parameters for this query.
|
protected void |
prepareReposition()
Prepare to process a reposition request by releasing the current
records, if any, in each buffer managed by the query.
|
protected boolean |
preserveBuffersOnEmptyResults(Results results)
Indicate whether the record buffer(s) current record(s) should be preserved, in the event
the query does not find any results.
|
boolean |
previous()
Retrieve the previous composite row of results for the query.
|
boolean |
previous(LockType lockType)
Retrieve the previous composite row of results for the query.
|
protected AbstractJoin |
processJoin(BufferReference primary,
BufferReference inverse)
Given a primary DMO buffer and an inverse DMO buffer which together
define a natural join, create the
AbstractJoin helper
object which is used to implement the join. |
java.util.Iterator<RecordBuffer> |
recordBuffers()
Report the record buffers for whose changes this object is interested
in listening.
|
protected void |
registerCleaner()
Register a
Finalizable with the transaction manager for
resource cleanup when this query's scope ends. |
void |
registerRecordChangeListeners(java.lang.Integer scope)
Register all
RecordChangeListeners associated with this
query (if any), with the context-local ChangeBroker at the
indicated scope. |
void |
releaseBuffers()
Release all buffers.
|
void |
reposition(int row)
Reposition the query to the specified row in the result set.
|
void |
reposition(NumberType row)
Reposition the cursor to the specified row in the result set.
|
boolean |
repositionByID(java.lang.Long... joinIDs)
Reposition the cursor such that a request to retrieve the next result will retrieve the
result which matches the specified array of primary key IDs.
|
protected boolean |
repositionByID(java.lang.Long[] ids,
boolean forceFetch)
Reposition the cursor such that a request to retrieve the next result
will retrieve the result which matches the specified array of primary
key IDs.
|
void |
repositionByID(recid id)
Reposition the cursor such that a request to retrieve the next result
will retrieve the result which matches the specified primary key ID.
|
void |
repositionByID(rowid id1,
rowid... joinIDs)
Reposition the cursor such that a request to retrieve the next result
will retrieve the result which matches the specified array of primary
key IDs.
|
void |
reset(boolean resolveArgs,
boolean forceOrigArgs)
Reset the query by clearing its state to a known default.
|
protected void |
resetResults()
Discard the current result set, clear the reposition cache, and reset
result-related state to default values.
|
void |
retry()
Provides a notification that the block whose scope in which the object
is registered is about to retry the same iteration (all loop control
data is unchanged).
|
boolean |
sessionEvent(SessionListener.Event event)
Respond to a clean (i.e., transaction commit) session event by caching
all preselected results and using that cache to back the query's results
for all future fetches.
|
protected void |
setEmptyBuffersUnknown()
Walk through each component and set its backing buffer to unknown mode,
such that the invocation of any of its DMO-backed methods returns
unknown value.
|
void |
setFullRecords()
Force the query to retrieve full records, rather than primary keys only.
|
void |
setIterationType(int iteration)
Set the iteration type for the most recently added query component.
|
void |
setIterationType(int iteration,
java.lang.String sort)
Set the iteration type for the most recently added query component.
|
void |
setLenientOffEnd(boolean lenientOffEnd)
Set the behavior of this query as a record retrieval request moves off
the end of its results.
|
void |
setNonScrolling()
Disable results list scrolling/repositioning (if it was enabled by
default).
|
void |
setResults(Results results)
Set the given results object into this query.
|
void |
setScrolling()
Override parent's no-op implementation to track whether client code has
set this as a scrollable query.
|
void |
setUnknownRecord()
Set each buffer backing a query component to unknown mode.
|
boolean |
shouldRegisterRecordChangeListeners()
Check if this type of query should register record change listeners.
|
protected boolean |
shouldUpdateAnyLock(LockType lockType)
Check if the lock should be updated for any component when fetching.
|
integer |
size()
Return the number of results found for this query.
|
void |
stateChanged(RecordChangeEvent event)
Respond to a
RecordChangeEvent. |
protected boolean |
supportsArbitraryIteration()
Does this query support non-NEXT iteration components?
|
java.lang.String |
toString()
Create a string representation of this object's state, primarily for debug purposes.
|
void |
translateWhere()
Translate the WHERE clause for all
components. |
protected boolean |
treatPreviousAsLast()
Indicate whether a call to move to the previous record in the result
list should be treated as a call to move to the last record in the list.
|
boolean |
unique()
Retrieve a unique record (only valid for a single-table query).
|
boolean |
unique(LockType lockType)
Retrieve a unique record (only valid for a single-table query),
overriding the default lock type of the underlying query component.
|
private boolean |
validateReposition(NumberType value)
Validate a numeric value provided to a reposition request to ensure
that it does not represent the unknown value.
|
private boolean |
validateRepositionByID(recid value)
Validate a record identifier provided to a reposition request to ensure
that it does not represent the unknown value.
|
private boolean |
validateRepositionByID(rowid value)
Validate a row identifier provided to a reposition request to ensure
that it does not represent the unknown value.
|
private boolean |
validateRepositionImpl(BaseDataType value,
int errorNum,
java.lang.String errorMsg)
Validate a numeric value provided to a reposition request to ensure
that it does not represent the unknown value.
|
protected boolean |
verifyJoins()
Invoked just before query execution, this method checks whether all
components with a non-null JOIN have a valid inverse on which to perform
the join.
|
protected java.util.Iterator<java.util.function.Supplier<logical>> |
whereExpressions()
Get an iterator on this query's client-side where expressions.
|
_getNext, _isSkipDeletedRecord, accumulate, addAccumulator, addAccumulator, addBuffer, addBuffer, addQueryEventListener, addRepositionListener, afterReposition, afterReposition, afterReposition, bufferHandle, bufferHandle, bufferHandle, bufferHandle, bufferHandle, buffersMatch, changeForwardOnly, changeForwardOnly, deleteResultListEntry, exclude, forwardOnly, getCache, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, getDataRelation, getDefaultLock, getErrorHelper, getExternalBuffersDefs, getFirst, getFirst, getFirst, getFirst, getFirst, getFirst, getFirst, getFirst, getLast, getLast, getLast, getLast, getLast, getLast, getLast, getLast, getNext, getNext, getNext, getNext, getNext, getNext, getNext, getNumResults, getPrevious, getPrevious, getPrevious, getPrevious, getPrevious, getPrevious, getPrevious, getPrevious, getReferencedBuffers, hasAccumulators, hasAny, hasAny, hasAny, hasAny, hasOne, hasOne, hasOne, hasOne, include, indexInformation, indexInformation, isBrowsed, isDynamicPredicate, isErrorIfNull, isFatalError, isFetchOnReposition, isFillingBrowseRows, isIndexedReposition, isIterating, isLastOfBreakGroup, isNewBreakGroup, isOffEnd, isOmitAlias, isOpen, isPresort, isRepositionNotificationActive, isSkipDeletedRecord, isStandalone, loadRowAtCursor, notifyQueryCloseListeners, notifyQueryOpenListeners, notifyRepositionListeners, numBuffers, numResults, numResults, prepare, prepare, prepareFetch, prepareString, preprocessSubstitutionArguments, queryBackward, queryBackward, queryClose, queryForward, queryForward, queryOpen, queryReposition, queryReposition, queryRepositionByID, removeRepositionListener, setBrowsed, setBuffers, setBuffers, setCache, setCache, setDataRelation, setDynamicPredicate, setErrorIfNull, setFatalError, setFetchOnReposition, setFillingBrowseRows, setIndexedReposition, setIterating, setOmitAlias, setOuter, setParameterFilter, setPresort, setSkipDeletedRecord, setStandalone, silentCurrent, silentCurrent, silentFirst, silentFirst, silentLast, silentLast, silentNext, silentNext, silentPrevious, silentPrevious, silentUnique, silentUnique, translateSort, translateSort, translateWhereclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclearResults, getReferencedBuffers, setErrorIfNull, setOuter_getNext, addAccumulator, addAccumulator, addQueryEventListener, addRepositionListener, changeForwardOnly, changeForwardOnly, deleteResultListEntry, exclude, forwardOnly, getBasicLogging, getCache, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, getDataRelation, getFirst, getFirst, getFirst, getFirst, getFirst, getFirst, getFirst, getFirst, getLast, getLast, getLast, getLast, getLast, getLast, getLast, getLast, getNext, getNext, getNext, getNext, getNext, getNext, getNext, getNext, getNumResults, getPrevious, getPrevious, getPrevious, getPrevious, getPrevious, getPrevious, getPrevious, getPrevious, hasAny, hasAny, hasAny, hasAny, hasOne, hasOne, hasOne, hasOne, hintFullResults, include, indexInformation, indexInformation, isBrowsed, isDynamicPredicate, isFetchOnReposition, isFillingBrowseRows, isFindByRowid, isFirstOfGroup, isFirstOfGroup, isIndexedReposition, isIterating, isLastOfGroup, isLastOfGroup, isOffEnd, isPresort, isSkipDeletedRecord, isStandalone, notifyQueryCloseListeners, notifyQueryOpenListeners, notifyRepositionListeners, prepare, prepare, prepareString, queryBackward, queryBackward, queryClose, queryForward, queryForward, queryOpen, queryReposition, queryReposition, queryRepositionByID, queryRepositionByID, removeRepositionListener, resetQuery, setBasicLogging, setBasicLogging, setBrowsed, setCache, setCache, setDataRelation, setDynamicPredicate, setFetchOnReposition, setFillingBrowseRows, setIndexedReposition, setIterating, setParameterFilter, setPresort, setSkipDeletedRecord, setStandaloneaddBuffer, addBuffer, addBuffer, addBuffer, bufferHandle, bufferHandle, bufferHandle, bufferHandle, bufferHandle, numBuffers, setBuffers, setBuffers, setBuffersentry, initFailure, weightprivate static final java.util.ArrayList<SortCriterion> EMPTY_ARRAY
private static final CentralLogger LOG
private static final NanoTimer QUERY_ASSEMBLE
assembleFQL().protected boolean betweenRows
protected OffEnd offEnd
protected java.lang.String sort
protected java.util.ArrayList<QueryComponent> components
protected boolean currentRowDeleted
protected boolean sortTranslated
sort has been translated.private java.util.List<java.util.function.Supplier<logical>> whereExprList
private Persistence persistence
private boolean scrolling
private final RepositionCache repoCache
private java.lang.String fql
private Results results
private boolean resolvableArgs
private int rowCount
private boolean regWithSession
private boolean regCleaner
protected boolean unregisterOnCleanup
private final Finalizable cleaner
private boolean thisFinalizable
private boolean fullRecords
private boolean forceOnlyId
private java.util.List<java.lang.String> dynamicSorts
private boolean whereTranslated
private static final boolean LOG_FINE
public PreselectQuery()
initialize() is
called.public PreselectQuery initialize(java.lang.String sort)
addComponent method variants.
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
sort - FQL order by clause to be applied across all components of the query.public PreselectQuery initialize(boolean lenientOffEnd, java.lang.String sort)
addComponent method variants.
This variant is used by code which is converted from an OPEN QUERY
statement, which permits advancing off the end of a result set without
raising a QueryOffEndException.
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
lenientOffEnd - true if advancing past either end of the result
set should NOT raise a QueryOffEndException;
false if doing so should raise the exception.sort - FQL order by clause to be applied across all components of the query.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, java.lang.String indexInfo)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, DataModelObject inverse)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.inverse - DMO to which this query should join via a foreign relation.
May be null.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, java.lang.String indexInfo, DataModelObject inverse)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.inverse - DMO to which this query should join via a foreign relation.
May be null.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, java.lang.Object[] args)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.args - Substitution parameters to be inserted into placeholders within
the where clause.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, java.lang.String indexInfo, java.lang.Object[] args)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.args - Substitution parameters to be inserted into placeholders within
the where clause.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, DataModelObject inverse, java.lang.Object[] args)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.inverse - DMO to which this query should join via a foreign relation.
May be null.args - Substitution parameters to be inserted into placeholders within
the where clause.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, java.lang.String indexInfo, DataModelObject inverse, java.lang.Object[] args)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.inverse - DMO to which this query should join via a foreign relation.
May be null.args - Substitution parameters to be inserted into placeholders within
the where clause.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, LockType lockType)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.lockType - Lock type to apply to records retrieved by this query.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, java.lang.String indexInfo, LockType lockType)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.lockType - Lock type to apply to records retrieved by this query.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, DataModelObject inverse, LockType lockType)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.inverse - DMO to which this query should join via a foreign relation.
May be null.lockType - Lock type to apply to records retrieved by this query.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, java.lang.String indexInfo, DataModelObject inverse, LockType lockType)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.inverse - DMO to which this query should join via a foreign relation.
May be null.lockType - Lock type to apply to records retrieved by this query.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, java.lang.Object[] args, LockType lockType)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.args - Substitution parameters to be inserted into placeholders within
the where clause.lockType - Lock type to apply to records retrieved by this query.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, java.lang.String indexInfo, java.lang.Object[] args, LockType lockType)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.args - Substitution parameters to be inserted into placeholders within
the where clause.lockType - Lock type to apply to records retrieved by this query.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, DataModelObject inverse, java.lang.Object[] args, LockType lockType)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.inverse - DMO to which this query should join via a foreign relation.
May be null.args - Substitution parameters to be inserted into placeholders within
the where clause.lockType - Lock type to apply to records retrieved by this query.public PreselectQuery initialize(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, java.lang.String indexInfo, DataModelObject inverse, java.lang.Object[] args, LockType lockType)
This code is intentionally separated from the constructor. The purpose of this separation is to allow construction to occur in the prior scope while initialization can still occur within a method or lambda that is inside the next block's scope.
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.whereExpr - Client-side where clause expression. May be null.sort - FQL order by clause.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.inverse - DMO to which this query should join via a foreign relation.
May be null.args - Substitution parameters to be inserted into placeholders within
the where clause.lockType - Lock type to apply to records retrieved by this query. If null, the default lock level
is assumed.public void translateWhere()
components.translateWhere in interface Joinablepublic void setLenientOffEnd(boolean lenientOffEnd)
next and previous which do not find a record
do not raise a QueryOffEndException. By default, this
would normally raise the exception.setLenientOffEnd in interface P2JQuerysetLenientOffEnd in class AbstractQuerylenientOffEnd - true to suppress QueryOffEndException
for next and previous requests;
false to permit these exceptions.public void addComponent(DataModelObject dmo, java.lang.String where)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.public void addComponent(DataModelObject dmo, java.lang.String where, java.lang.String indexInfo)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.public void addComponent(DataModelObject dmo, java.lang.String where, DataModelObject inverse)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.inverse - DMO to which this query should join via a foreign relation.
May be null.public void addComponent(DataModelObject dmo, java.lang.String where, java.lang.String indexInfo, DataModelObject inverse)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.inverse - DMO to which this query should join via a foreign relation.
May be null.public void addComponent(DataModelObject dmo, java.lang.String where, java.lang.Object[] args)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.args - Substitution parameters to be inserted into placeholders within
the where clause.public void addComponent(DataModelObject dmo, java.lang.String where, java.lang.String indexInfo, java.lang.Object[] args)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.args - Substitution parameters to be inserted into placeholders within
the where clause.public void addComponent(DataModelObject dmo, java.lang.String where, DataModelObject inverse, java.lang.Object[] args)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.inverse - DMO to which this query should join via a foreign relation.
May be null.args - Substitution parameters to be inserted into placeholders within
the where clause.public void addComponent(DataModelObject dmo, java.lang.String where, java.lang.String indexInfo, DataModelObject inverse, java.lang.Object[] args)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.inverse - DMO to which this query should join via a foreign relation.
May be null.args - Substitution parameters to be inserted into placeholders within
the where clause.public void addComponent(DataModelObject dmo, java.lang.String where, LockType lockType)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.lockType - Lock type to apply to records retrieved by this component of
the query.public void addComponent(DataModelObject dmo, java.lang.String where, java.lang.String indexInfo, LockType lockType)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.lockType - Lock type to apply to records retrieved by this component of
the query.public void addComponent(DataModelObject dmo, java.lang.String where, DataModelObject inverse, LockType lockType)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.inverse - DMO to which this query should join via a foreign relation.
May be null.lockType - Lock type to apply to records retrieved by this component of
the query.public void addComponent(DataModelObject dmo, java.lang.String where, java.lang.String indexInfo, DataModelObject inverse, LockType lockType)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.inverse - DMO to which this query should join via a foreign relation.
May be null.lockType - Lock type to apply to records retrieved by this component of
the query.public void addComponent(DataModelObject dmo, java.lang.String where, java.lang.Object[] args, LockType lockType)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.args - Substitution parameters to be inserted into placeholders within
the where clause.lockType - Lock type to apply to records retrieved by this component of
the query.public void addComponent(DataModelObject dmo, java.lang.String where, java.lang.String indexInfo, java.lang.Object[] args, LockType lockType)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.args - Substitution parameters to be inserted into placeholders within
the where clause.lockType - Lock type to apply to records retrieved by this component of
the query.public void addComponent(DataModelObject dmo, java.lang.String where, DataModelObject inverse, java.lang.Object[] args, LockType lockType)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.inverse - DMO to which this query should join via a foreign relation.
May be null.args - Substitution parameters to be inserted into placeholders within
the where clause.lockType - Lock type to apply to records retrieved by this component of
the query.public void addComponent(DataModelObject dmo, java.lang.String where, java.lang.String indexInfo, DataModelObject inverse, java.lang.Object[] args, LockType lockType)
NEXT iteration type
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.inverse - DMO to which this query should join via a foreign relation.
May be null.args - Substitution parameters to be inserted into placeholders within
the where clause.lockType - Lock type to apply to records retrieved by this component of
the query.public void addComponent(DataModelObject dmo, java.lang.String where, java.lang.Object[] args, LockType lockType, int iteration, boolean outer)
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.args - Substitution parameters to be inserted into placeholders within
the where clause.lockType - Lock type to apply to records retrieved by this component of
the query.iteration - Iteration/retrieval mode for this component of the query. At
this time, only NEXT is supported. Future
support for FIRST, LAST, and
UNIQUE is expected.outer - true if an outer join is required. At this time,
only inner joins are supported. Future support for outer
joins is expected.java.lang.UnsupportedOperationException - if outer is true (temporary);
if iteration is not NEXT (temporary);
if dmo's associated database is different than
that of a previously added component's database (cross-database
preselect joins are not possible).public void addComponent(DataModelObject dmo, java.lang.String where, java.lang.String indexInfo, java.lang.Object[] args, LockType lockType, int iteration, boolean outer)
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.args - Substitution parameters to be inserted into placeholders within
the where clause.lockType - Lock type to apply to records retrieved by this component of
the query.iteration - Iteration/retrieval mode for this component of the query. At
this time, only NEXT is supported. Future
support for FIRST, LAST, and
UNIQUE is expected.outer - true if an outer join is required. At this time,
only inner joins are supported. Future support for outer
joins is expected.java.lang.UnsupportedOperationException - if outer is true (temporary);
if iteration is not NEXT (temporary);
if dmo's associated database is different than
that of a previously added component's database (cross-database
preselect joins are not possible).public void addComponent(DataModelObject dmo, java.lang.String where, DataModelObject inverse, java.lang.Object[] args, LockType lockType, int iteration, boolean outer)
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.inverse - DMO to which this query should join via a foreign relation.
May be null.args - Substitution parameters to be inserted into placeholders within
the where clause.lockType - Lock type to apply to records retrieved by this component of
the query.iteration - Iteration/retrieval mode for this component of the query. At
this time, only NEXT is supported. Future
support for FIRST, LAST, and
UNIQUE is expected.outer - true if an outer join is required. At this time,
only inner joins are supported. Future support for outer
joins is expected.java.lang.UnsupportedOperationException - if outer is true (temporary);
if iteration is not NEXT (temporary);
if dmo's associated database is different than
that of a previously added component's database (cross-database
preselect joins are not possible).public void addComponent(DataModelObject dmo, java.lang.String where, java.lang.String indexInfo, DataModelObject inverse, java.lang.Object[] args, LockType lockType, int iteration, boolean outer)
dmo - DMO proxy which defines buffer and record type.where - FQL where clause. May be null.indexInfo - Index information string as it is returned by INDEX-INFORMATION.
May be null if it is not an OPEN QUERY case or if
you don't need debug information about selected indexes.inverse - DMO to which this query should join via a foreign relation.
May be null.args - Substitution parameters to be inserted into placeholders within
the where clause.lockType - Lock type to apply to records retrieved by this component of
the query.iteration - Iteration/retrieval mode for this component of the query. At
this time, only NEXT is supported. Future
support for FIRST, LAST, and
UNIQUE is expected.outer - true if an outer join is required. At this time,
only inner joins are supported. Future support for outer
joins is expected.java.lang.UnsupportedOperationException - if outer is true (temporary);
if iteration is not NEXT (temporary);
if dmo's associated database is different than
that of a previously added component's database (cross-database
preselect joins are not possible).public RecordBuffer[] getExternalBuffers()
getExternalBuffers in interface JoinablegetExternalBuffers in class AbstractQuerynull.public boolean shouldRegisterRecordChangeListeners()
shouldRegisterRecordChangeListeners in interface Joinabletrue if we should invest time into computing the scope in order
to call registerRecordChangeListeners(java.lang.Integer) or false if we
can skip doing any work to honor registerRecordChangeListeners(java.lang.Integer).public void registerRecordChangeListeners(java.lang.Integer scope)
RecordChangeListeners associated with this
query (if any), with the context-local ChangeBroker at the
indicated scope.
This implementation does nothing.
registerRecordChangeListeners in interface Joinablescope - Scope at which listeners should be registered with the change
broker.public java.util.Iterator<RecordBuffer> recordBuffers()
ChangeBroker to receive notifications of any change to DMOs whose
interface types match those returned by the RecordBuffer.getDMOInterface() methods of the returned buffers.recordBuffers in interface RecordChangeListenerpublic void stateChanged(RecordChangeEvent event) throws PersistenceException
RecordChangeEvent.stateChanged in interface RecordChangeListenerevent - Event which describes the DMO state change.PersistenceException - if any error occurs while processing the state change event.public boolean sessionEvent(SessionListener.Event event) throws PersistenceException
Respond to a session closing event by clearing all results, unless they were just cached as described above.
sessionEvent in interface SessionListenerevent - Session event type.true, indicating this query should be
deregistered as a session listener after this method returns;
else false.PersistenceException - if there is an error caching results.public void deregisteredSessionListener()
deregisteredSessionListener in interface SessionListenerpublic void finished()
finished in interface Finalizablepublic void deleted()
This is a no-op implementation required by the interface.
deleted in interface Finalizablepublic void iterate()
iterate in interface Finalizablepublic void retry()
next() at the top of the block body from
advancing to the next row.
This implementation retries the current record only if the query is
associated with a FOR block (see BlockType).
retry in interface Finalizablepublic java.lang.String toString()
toString in class java.lang.Objectpublic void addWhereExpression(java.util.function.Supplier<logical> whereExpr)
whereExpr - Client-side where clause expression. May not be
null.java.lang.NullPointerException - if whereExpr is null.public void setIterationType(int iteration)
iteration - Retrieval mode from QueryConstants. Must not be FIRST or LAST (use
setIterationType(int, String) instead for these types.java.lang.IllegalStateException - If no component has yet been added.java.lang.IllegalArgumentException - If iteration type is FIRST or LAST.public void setIterationType(int iteration,
java.lang.String sort)
iteration - Retrieval mode from QueryConstants.sort - Order by clause which should be associated with the most recently added query
component. Must be non-null for iteration types FIRST
and LAST.java.lang.IllegalStateException - If no component has yet been added.java.lang.IllegalArgumentException - If iteration type is FIRST or LAST, but
sort is null, or if sort represents an
invalid FQL order by expression.public boolean first()
If the query involves outer joins, some of the underlying buffers may be empty when this method returns.
first in interface P2JQuerytrue if query could retrieve the first record sucefully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records
are available and the query is set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail
in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean first(LockType lockType)
If the query involves outer joins, some of the underlying buffers may be empty when this method returns.
first in interface P2JQuerylockType - Lock type to apply to records retrieved (overrides default
lock type set for each query component).true if query could retrive the first record succefully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records
are available and the query is set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail
in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean last()
If the query involves outer joins, some of the underlying buffers may be empty when this method returns.
last in interface P2JQuerytrue if query could retrive the last record succefully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records
are available and the query is set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail
in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean last(LockType lockType)
If the query involves outer joins, some of the underlying buffers may be empty when this method returns.
last in interface P2JQuerylockType - Lock type to apply to records retrieved (overrides default
lock type set for each query component).true if query could retrive the last record succefully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records
are available and the query is set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail
in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean next()
If the query involves outer joins, some of the underlying buffers may be empty when this method returns.
next in interface P2JQuerytrue if query could retrive the next record succefully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records
are available and the query is set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail
in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean next(LockType lockType)
If the query involves outer joins, some of the underlying buffers may be empty when this method returns.
next in interface P2JQuerylockType - Lock type to apply to records retrieved (overrides default
lock type set for each query component).true if query could retrive the next record succefully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records
are available and the query is set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail
in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean previous()
If the query involves outer joins, some of the underlying buffers may be empty when this method returns.
previous in interface P2JQuerytrue if query could retrive the previous record succefully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records
are available and the query is set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail
in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean previous(LockType lockType)
If the query involves outer joins, some of the underlying buffers may be empty when this method returns.
previous in interface P2JQuerylockType - Lock type to apply to records retrieved (overrides default
lock type set for each query component).true if query could retrive the previous record succefully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query or the fetch of any record fails, or if no records
are available and the query is set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail
in this case.java.lang.IllegalStateException - if no query component has been added to this query.public boolean unique()
unique in interface P2JQuerytrue if query could retrive the unique record succefully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query fails or if more than one result is found which
matches the query criteria.java.lang.UnsupportedOperationException - if this method is invoked on a multi-table query.java.lang.IllegalStateException - if no query component has been added to this query.public boolean unique(LockType lockType)
unique in interface P2JQuerylockType - Lock type which should override that of the query component.true if query could retrive the unique record succefully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the query fails or if more than one result is found which
matches the query criteria.java.lang.UnsupportedOperationException - if this method is invoked on a multi-table query.java.lang.IllegalStateException - if no query component has been added to this query.public boolean current()
If the query involves outer joins, some of the underlying buffers may be empty when this method returns.
current in interface P2JQuerytrue if query could retrive the current record succefully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the reload triggers an error.java.lang.IllegalStateException - if no query component has been added to this query.public boolean current(LockType lockType)
If the query involves outer joins, some of the underlying buffers may be empty when this method returns.
current in interface P2JQuerylockType - Lock type which should override that of any query component.true if query could retrive the current record succefully;
false if unsuccessful and lenientOffEnd is set on true.ErrorConditionException - if the reload triggers an error.java.lang.IllegalStateException - if no query component has been added to this query.public void load(java.lang.Object[] data,
LockType lockType,
boolean silentIfNullId)
throws PersistenceException
In the event an expected value cannot be loaded (e.g., the record has been deleted or is otherwise no
longer available), this method throws MissingRecordException, after setting the associated
buffer(s) into unknown mode. Note that a record being locked by
another session does not constitute a "missing" record. Note also that this exception is not thrown
until all the elements of data have been processed to the extent possible.
If the QueryComponent is not the first component in components()
and the query attached to it is an OUTER-JOIN, we set the buffer into
unknown mode otherwise the buffer is released and the method
returns immediately.
load in interface Joinabledata - Array of primary key IDs or DMOs, one per table involved in the query.lockType - Lock type which should by used. Set to null to allow query to use its current lock
type.silentIfNullId - Do not raise MissingRecordException if some of the provided IDs are null.
null IDs are valid for queries with OUTER join.MissingRecordException - if any record cannot be loaded, because it is no longer available (e.g., deleted, etc.).PersistenceException - if there is an error loading data.Joinable.getRow()public java.util.ArrayList<QueryOffEndListener> getOffEndListeners()
getOffEndListeners in interface P2JQuerypublic java.lang.Object[] getRow()
getRow in interface Joinableload(Object[], LockType, boolean)public void repositionByID(recid id)
repositionByID in interface P2JQueryid - A primary key ID, representing the target record (in the case
of a join, this ID is associated with the left-most record in
the join).ErrorConditionException - if the specified ID represents the unknown value.public void repositionByID(rowid id1, rowid... joinIDs)
repositionByID in interface P2JQueryid1 - A primary key ID, representing the target record (in the case
of a join, this ID is associated with the left-most record in
the join).joinIDs - All remaining primary key IDs, if any, arranged from left to
right to coincide with the records being joined by the
underlying query.ErrorConditionException - if any of the specified IDs represents the unknown value.public boolean repositionByID(java.lang.Long... joinIDs)
repositionByID in interface P2JQueryjoinIDs - A set of primary key IDs, arranged from left to right to coincide with the records
being joined by the underlying query.true on success.ErrorConditionException - if any of the specified IDs represents the unknown value.public void reposition(NumberType row)
reposition in interface P2JQueryrow - 1-based index of the target position.ErrorConditionException - if row represents unknown value.public void reposition(int row)
reposition in interface P2JQueryrow - 1-based index of the target position.ErrorConditionException - if there is an error repositioning the cursor.public boolean forward(NumberType rows)
forward in interface P2JQueryrows - Number of rows to scroll the cursor forward.true if operation was successful and the cursor was moved the exact amount
of rows as specified by the parameter. If false is returned then it is
possible that cursor's position was moved but not with rows rows.ErrorConditionException - if rows represents the unknown value; if there is an error repositioning
the cursor.public boolean forward(int rows)
forward in interface P2JQueryrows - Number of rows to scroll the cursor forward.true if operation was successful and the cursor was moved the exact amount
of rows as specified by the parameter. If false is returned then it is
possible that cursor's position was moved but not with rows rows.ErrorConditionException - if there is an error repositioning the cursor.public boolean backward(NumberType rows)
backward in interface P2JQueryrows - Number of rows to scroll the cursor backward.true if operation was successful and the cursor was moved the exact amount
of rows as specified by the parameter. If false is returned then it is
possible that cursor's position was moved but not with rows rows.ErrorConditionException - if rows represents the unknown value; if there is an error repositioning
the cursor.public boolean backward(int rows)
backward in interface P2JQueryrows - Number of rows to scroll the cursor backward.true if operation was successful and the cursor was moved the exact amount
of rows as specified by the parameter. If false is returned then it is
possible that cursor's position was moved but not with rows rows.ErrorConditionException - if there is an error repositioning the cursor.public integer size()
Note that the first time this method is invoked, the database server may have to scroll to the end of the result set, which may be a time-consuming process for a large result set.
public integer currentRow()
currentRow in interface P2JQuerypublic integer currentRowImpl()
currentRowImpl in interface P2JQuerypublic boolean _isOffEnd()
public boolean isFullRecords()
true to return full records; false to return primary
keys only.public void setFullRecords()
setFullRecords in interface Joinablepublic void reset(boolean resolveArgs,
boolean forceOrigArgs)
This implementation nulls out the current result set, so that the next record retrieval request triggers a new server-side query. Optionally, it also resets resolvable substitution arguments and triggers where expression arguments to be resolved, if a client-side where cause expression is defined.
reset in interface JoinableresolveArgs - true if query substitution arguments should be
resolved/reset as part of the reset; false if
existing argument values should be used for the next query
execution.forceOrigArgs - Flag indicating that the original arguments used at the construction of the query must be
re-calculated.public void setUnknownRecord()
setUnknownRecord in interface JoinableRecordBuffer.setUnknownMode()public int getTableCount()
getTableCount in interface P2JQuerypublic java.lang.Object[] peekFirst()
public java.lang.Object[] peekLast()
public java.lang.Object[] peekNext()
peekNext in interface Scrollablenull if there is no such result.public java.lang.Object[] peekPrevious()
peekPrevious in interface Scrollablenull if there is no such result.public boolean isPreselect()
isPreselect in interface P2JQuerytrue.public void setResults(Results results)
setResults in interface Joinableresults - New result set for this query.public RecordBuffer[] getRecordBuffers()
getRecordBuffers in interface P2JQuerypublic java.lang.Object[] getArgs()
public java.lang.String getOriginalWhere()
getOriginalWhere in interface Joinablenull if there is none.public AbstractJoin getJoin()
public void forceDynamicOperation()
forceDynamicOperation in interface Joinablejava.lang.UnsupportedOperationException - always; this query type does not support dynamic retrieval.public java.lang.String getSortPhrase()
getSortPhrase in interface Joinablepublic AdaptiveComponent makeAdaptiveServerJoinComponent(java.util.List<AdaptiveComponent> joinList, AdaptiveQuery query, int iteration, boolean outer, CompoundComponent fallback)
makeAdaptiveServerJoinComponent in interface JoinablejoinList - List of adaptive components representing nested query loops which will contain
the adaptive query component returned by this method. The last component in the
list represents the nested query loop immediately containing the returned query
component, with which the join will be made.query - Adaptive query which will manage the server-side join of joinList and
the returned query component.iteration - Iteration type: FIRST, LAST, or NEXT.outer - true if the join should be a left outer join. This type of join is
not supported at the time of this writing, so this parameter should always be
false. It is here to support a planned, future enhancement.fallback - A compound query component to use in the event the multi-table adaptive query
switches from preselect to dynamic retrieval mode.public QueryComponent makePreselectServerJoinComponent(java.util.List<QueryComponent> joinList, int iteration, boolean outer)
makePreselectServerJoinComponent in interface JoinablejoinList - List of preselect components representing nested query loops which will contain
the preselect query component returned by this method. The last component in the
list represents the nested query loop immediately containing the returned query
component, with which the join will be made.iteration - Iteration type: FIRST, LAST, or NEXT.outer - true if the join should be a left outer join. This type of join is
not supported at the time of this writing, so this parameter should always be
false. It is here to support a planned, future enhancement.public boolean hasWhereExpression()
hasWhereExpression in interface Joinabletrue if there is a where expression; else false.public void cleanup()
cleanup in interface P2JQuerycleanup in class AbstractQueryP2JQuery.cleanup()public void open()
open in interface P2JQueryopen in class AbstractQuerypublic void close()
This will remove any registered finalizable.
close in interface P2JQueryclose in class AbstractQuerypublic void close(boolean inResource)
public void setScrolling()
setScrolling in interface P2JQuerysetScrolling in class AbstractQuerypublic void setNonScrolling()
public OffEnd getOffEnd()
public void releaseBuffers()
releaseBuffers in interface P2JQueryreleaseBuffers in class AbstractQuerypublic boolean addDynamicFilter(FieldReference fr, BaseDataType val, java.lang.String format)
new-where := (fr = val) AND (old-query).
Note: The constraints are exclusive meaning that if constraints will be added for same field of same buffer, the query will return an empty result because the field cannot be at the same time equals to two different values.
Use clearDynamicFilters() to clean all dynamically added criteria and restore the
sorting order of the query to its original form.
addDynamicFilter in interface P2JQueryfr - A reference to field used as filtering criterion. Only the rows that matches the
specified value for this field will be selected. Must not be null.val - The filtering value for this constraint. Can be null or unknown, in
which case the SQL null value will be assumed. In this case the predicate
will look like:
new-where := (fr IS NULL) AND (old-query)
format - The format to be used when comparing values. The reason for this parameter is that
for some datatype (ex: decimal) the on-screen value can be different from
the database (because of rounding).true if the filtering constraint was successfully added. If the field
reference is not related to the buffer(s) of this query, false is returned.public void clearDynamicFilters()
clearDynamicFilters in interface P2JQueryvoid addDynamicSortCriterion(FieldReference fr, boolean asc)
Use clearDynamicSortCriteria() to clean all dynamically added criteria and restore the
sorting order of the query to its original form.
fr - A reference to field used as new strongest criterion. The current criteria will
be kept, but with lower priority.asc - The direction of sorting for this criterion. Use true for ascending sort
and false for descending sorting.void clearDynamicSortCriteria()
public character indexInformation(NumberType n)
Getter of INDEX-INFORMATION attribute
indexInformation in interface IndexInformationindexInformation in interface P2JQueryindexInformation in class AbstractQueryn - An integer expression that evaluates to the level of join for which you want index
information.public boolean isNativelyPreselect()
isNativelyPreselect in interface P2JQuerytrue.public logical createResultListEntry()
createResultListEntry in interface P2JQuerycreateResultListEntry in class AbstractQuerytrue on success.public logical deleteResultListEntry(boolean allowBetweenRows)
deleteResultListEntry in interface P2JQuerydeleteResultListEntry in class AbstractQueryallowBetweenRows - If true then the cursor can be positioned between rows (the next
row will be deleted). false for conventional DELETE-RESULT-LIST-ENTRY()
mode where the cursor should be positioned on a row (otherwise false is
returned).true on success.public boolean isScrolling()
scrolling flag has been set.isScrolling in interface P2JQuerytrue if this is a scrolling query; else
false.protected boolean isNativelyScrolling()
Subclasses which are not natively scrolling should override this method.
true.public P2JQuery addExternalBuffers(DataModelObject... dmos)
If the bound buffer differs from the definition buffer (see AbstractQuery.buffersMatch(com.goldencode.p2j.persist.RecordBuffer, com.goldencode.p2j.persist.RecordBuffer)) for any of the
external buffers, then all components() will have the translateWhere() enabled
(if not already enabled).
addExternalBuffers in interface P2JQueryaddExternalBuffers in class AbstractQuerydmos - One or more external buffers.protected void resetResults()
protected java.util.ArrayList<QueryComponent> components()
protected boolean isLenientOffEnd()
QueryOffEndException when it runs off the end of its
results.isLenientOffEnd in class AbstractQuerytrue if an exception will be thrown, else
false.protected boolean treatPreviousAsLast()
true to treat a previous request as a request to
move to the last record in the list; else false.protected void setEmptyBuffersUnknown()
protected AbstractJoin processJoin(BufferReference primary, BufferReference inverse)
AbstractJoin helper
object which is used to implement the join.
It is intended that this method be called when adding a query component.
If no previous components have been added, a DynamicJoin
is created, and it is assumed that the inverse DMO is provided as a
query substitution parameter. If a component previously has been added,
a ServerJoin is created, and it is assumed that the inverse
DMO will be resolved by a server-side join, rather than being provided
as a query substitution parameter.
If no inverse buffer is provided, no join is created.
primary - Buffer reference to the primary DMO.inverse - Buffer reference to the joined DMO, or null if no
join is required.null if no natural join
is required.protected void assembleSelectClause(java.lang.StringBuilder buf)
select {buffer0.id} [, {buffer1.id} [...]]
buf - String buffer into which clause is assembled.protected FQLExpression assembleFromAndWhereClauses(java.util.ArrayList<SortCriterion> sortCriteria) throws PersistenceException
from {Buffer0} as {buffer0}
[[left outer] join {Buffer1} as {buffer1} on {JoinCondition1} [and {JoinCondition1_1}] [...]
[, {Buffer2} as buffer2 [...]]
[[left outer] join {Buffer3} as {buffer3} on {JoinCondition2} [and {JoinCondition2_1}] [...]]]
[, {Buffer4} as buffer4 [...]]
[where {WhereCondition1} [and {WhereCondition2}] [...]]]
The FQL is creating by adding first the "from" KEYWORD, followed by:
1) possible one or more different types of joins, each with one or more join conditions.
2) not joined buffers.
At the end, the complete where clause is appended at the end of the FQL.
sortCriteria - All known sort criteria. If a JOIN term is detected in the preprocessed query this list is
simplified to allow a cleaner ORDER BY clause and let the query planner chose a better plan.PersistenceException - if there is an error creating the FQLPreprocessor from which the composite join data
are gathered.protected void assembleWhereClause(java.util.ArrayList<SortCriterion> sortCriteria, int indices, FQLExpression whereClause, FQLExpression onClause, boolean isOn) throws PersistenceException
where ({component0_clause})
[and ({component1_clause})
[...]]
sortCriteria - List of SortCriterion objects which describe the
sort behavior for this query.indices - int which represents the position of the component we generate
the where clause for.whereClause - FQLExpression which represents the variable where the "where" clause is
going to be saved.onClause - FQLExpression which represents the variable where the "on" clause is
going to be saved.isOn - boolean that will help to distinguish between "where" and "and" and "on".PersistenceException - if there is an error creating the FQLPreprocessor
from which the preprocessed where clause is retrieved for each
query component.protected java.util.ArrayList<SortCriterion> assembleOrderByClause() throws PersistenceException
order by clause for an FQL query.
Any text-based sort criteria are augmented with the necessary upper() and rtrim() functions.
SortCriterion objects which describe the sort behavior for this query.PersistenceException - if the raw sort clause provided at construction contains any unqualified property names;
if the raw sort clause contains a reference to an unrecognized record buffer.private void generateOrderBy(java.util.ArrayList<SortCriterion> sortCriteria, java.lang.StringBuilder buf)
order by clause starting from the list of criteria, including the "order by"
keyword. Uses the form:
order by {{dmo.property} {asc/desc}} [, ...]
sortCriteria - The list of criteria to be added.buf - The string builder to add the result.protected java.util.List<SortCriterion> assembleOrderByClause(java.lang.String sort) throws PersistenceException
order by clause for an FQL query.
Any text-based sort criteria are augmented with the necessary upper() and rtrim() functions.
sort - Raw sort clause to parse and augment if necessary.SortCriterion objects which describe the sort behavior for this query.PersistenceException - if sort contains any unqualified property names;
if sort clause contains a reference to an unrecognized record buffer.protected java.util.ArrayList<SortCriterion> buildSortCriteria(java.lang.String sort) throws PersistenceException
SortCriterion objects build from the given sort clause.sort - Raw sort clause to parse and augment if necessary.SortCriterion objects which describe the
sort behavior for this query.PersistenceException - if sort contains any unqualified property names;
if sort clause contains a reference to an
unrecognized record buffer.protected java.util.ArrayList<SortCriterion> assembleOrderByClause(java.util.List<SortCriterion> sortCriteria)
order by clause for an FQL query.
Any text-based sort criteria are augmented with the necessary upper() and rtrim() functions.
sortCriteria - A list of SortCriterion objects which describe the sorting to be applied.SortCriterion objects which describe the sort behavior for this query.protected java.util.List<java.util.function.Supplier<logical>> getWhereExpressions()
protected java.util.Iterator<java.util.function.Supplier<logical>> whereExpressions()
protected boolean execute()
true if query was executed for the first time;
false if query was executed previously and we
already have a result set.ErrorConditionException - if an error occurs executing the query.java.lang.IllegalStateException - if no query component has been added to this query.protected boolean isTopLevelCleanup()
This default implementation returns false, indicating
results should be cleaned up at the nearest enclosing scope.
Subclasses which require different behavior must override this method.
false.protected boolean verifyJoins()
true if verification succeeded and query execution
should continue; else falseprotected void handleMissingJoinRecord()
This implementation creates an empty result set.
protected Results cacheResults(Results target)
Results
instance. If this is a scrolling query, this will cache all results in the target result
set, including those already visited. Otherwise, only the current result and all remaining,
unvisited results are cached.target - Result set which is to be cached, presumably because it will be invalid
momentarily. If results previously were cached, target is simply returned.target, if any, cached in a Results object. If there
were no results available to cache, an empty result set is returned. If any of
the record buffers backing this query have been closed, null is returned.protected void prepareParameters(java.util.List<java.lang.Object> args)
throws PersistenceException
args list for each ? placeholder in the FQL query string for this query.args - Argument list to be populated.PersistenceException - if there is an error creating an FQLPreprocessor during the gathering of
query substitution parameters.protected java.lang.String[] getEntities()
protected java.lang.Long getTemplateQueryRowid(java.lang.Object[] args)
Note:
The current implementation identifies only simple queries for template records:
PreselectQuery has a single component;FQLPreprocessor of the component);FOR EACH book WHERE RECID(book) = templateId OR book.isbn NE ?
On the other hand, it does not make much sense to:
args - The actual parameters of the query.null otherwise.protected Results executeQuery(Persistence persistence, java.lang.String fql, java.lang.Object[] args) throws PersistenceException
This default implementation returns an object which is a thin wrapper around
ScrollableResults. Subclasses may override this method if they need a
Results implementation other than ScrollingResults.
In case when the fql represents a valid template record query (a test on recid /
rowid of the record against the unique _file._template for current record of the
single QueryComponent), a special Results object is returned with a single
element that is the template record for the buffer of the component.
persistence - Object which is used to execute the query.fql - FQL query string.args - Substitution parameters to be inserted into placeholders within the FQL query string.ScrollingResults which wrappers the
ScrollableResults object returned by the execution of the query.PersistenceException - if there is an error executing the query.protected <T> ScrollableResults<T> executeScroll(Persistence persistence, java.lang.String fql, java.lang.Object[] args) throws PersistenceException
ScrollableResults result set.persistence - Object which is used to execute the query.fql - FQL query string.args - Substitution parameters to be inserted into placeholders within
within the FQL query string.ScrollableResults object returned by the execution of the query.PersistenceException - if there is an error executing the query.protected Results createResults(Results results) throws PersistenceException
Results implementation (for client-side where processing).
It is this object which actually will be used to retrieve the primary
key values of records to be loaded from the database.
If no filtering is necessary, simply return the results object which was passed in.
Subclasses may override this method to insert their own layers into result set processing.
results - An object which manipulates the database result set returned
from execution of the query.Results object.PersistenceException - if there is any error creating results.protected void fetch(boolean available,
LockType lockType,
boolean errorIfNull)
throws MissingRecordException
As particular case when the query looks for the template record of the buffer of the single
QueryComponent, the buffer is not populated with a record fetched from backing
database, instead the template record for the buffer is automatically created in-memory.
This results object has only one element to iterate on and attempting to iterate on
this object will throw QueryOffEndException and release the buffer.
available - true if the most recent scrollable cursor move left the cursor at an
available result row; false if the cursor cannot read a result at its
current position.lockType - Overriding lock type to apply to fetched records. If null, default lock
types are applied.errorIfNull - true if failed retrievals should raise error.MissingRecordException - if the record was expected to be available, but wasn't. This typically indicates
the record was deleted between the time it initially was found by the query and the
time it was to be fetched to store in the record buffer.ErrorConditionException - if the fetch of any record fails or if no records are available and the query is
set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail in this case.protected final boolean coreFetch(java.lang.Object[] data,
LockType lockType,
boolean errorIfNull,
boolean silentIfNullId)
throws PersistenceException
data - An array of primary key IDs or DMOs representing records to be fetched for the composite row.lockType - Overriding lock type to apply to fetched records. If null, default lock types are
applied.errorIfNull - true if failed retrievals should raise error.silentIfNullId - If true, do not raise QueryOffEndException if some of the provided IDs are
null.null IDs are valid for queries with OUTER join.true if data was fetched and is available and false is the fetch failed and no
error was raised (when errorIfNull is false).MissingRecordException - if the record was expected to be available, but wasn't. This typically indicates the record
was deleted between the time it initially was found by the query and the time it was to be
fetched to store in the record buffer.PersistenceException - if the fetch of any record fails.ErrorConditionException - if no records are available and the query is set to fail in this case.QueryOffEndException - if no records are available and the query is set not to fail in this case.protected final boolean isClientWhere()
true if client-side filter is required, else
false.protected Results getResults()
Results object for this query.Results object.protected void addComponent(QueryComponent comp)
comp - Query component to be added.java.lang.UnsupportedOperationException - if attempting an outer join (temporary);
if iteration type is not NEXT (temporary);
if the component's DMO's associated database is different than
that of a previously added component's database (cross-database
preselect joins are not possible).protected boolean supportsArbitraryIteration()
falseprotected boolean preserveBuffersOnEmptyResults(Results results)
This implementation always returns false. Subclasses should override this behavior if needed.
results - The results instance to decide if they are truly empty. The results are not visible
in some sub-classes, so let them be passed by parameter.false.protected void clearRepoCache()
protected java.lang.String getHQL()
null if the query has not yet been executed.protected Persistence getPersistence()
protected void registerCleaner()
Finalizable with the transaction manager for
resource cleanup when this query's scope ends.protected boolean repositionByID(java.lang.Long[] ids,
boolean forceFetch)
ids - Array of primary key IDs, arranged from left to right to
coincide with the records being joined by the underlying
query.forceFetch - true to override the current fetch-on-reposition
setting to true, in case the underlying
Results implementation attempts to fetch the
record during repositioning; false to honor the
current setting.true if reposition was successful;
false if unsuccessful.ErrorConditionException - if there is an error repositioning the cursor.protected void prepareReposition()
protected boolean anyBoundBufferInComponent()
protected boolean shouldUpdateAnyLock(LockType lockType)
LockType.NONE, no lock update should happen. If the component specific
lock mode is used, ensure that there is no particular (SHARE or EXCLUSIVE) lock
request for any component, which may trigger fetching.lockType - The lock mode for the records after query execution.true if one of the components has a record which should be fetched
with another lock type.private QueryComponent findComponent(RecordBuffer buffer)
buffer - Record buffer.null if not found.private java.lang.String assembleFQL()
throws PersistenceException
PersistenceException - if the sort criteria reference unqualified or unrecognized
buffer names.private void assembleFQLImpl(java.lang.StringBuilder buf)
throws PersistenceException
PersistenceException - if the sort criteria reference unqualified or unrecognized
buffer names.private boolean isOrderByRequired()
throws PersistenceException
true if the ORDER BY clause is necessary for the query,
false otherwise.PersistenceExceptionprivate boolean validateRepositionByID(rowid value)
value - ID to be validated.true if the number is valid; false
if it is invalid, but we are in silent error mode.ErrorConditionException - if the number is invalid and we are not in silent error mode.private boolean validateRepositionByID(recid value)
value - ID to be validated.true if the number is valid; false
if it is invalid, but we are in silent error mode.ErrorConditionException - if the number is invalid and we are not in silent error mode.private boolean validateReposition(NumberType value)
value - ID or row number/offset to be validated.true if the number is valid; false
if it is invalid, but we are in silent error mode.ErrorConditionException - if the number is invalid and we are not in silent error mode.private boolean validateRepositionImpl(BaseDataType value, int errorNum, java.lang.String errorMsg)
value - ID or row number/offset to be validated.errorNum - Error number if validation fails.errorMsg - Error message if validation fails.true if the number is valid; false
if it is invalid.ErrorConditionException - if the number is invalid and we are not in silent error mode.private boolean isResultSetCached()
true if there is a result set and it has been cached.