public final class FindQuery extends RandomAccessQuery
RandomAccessQuery
. Calls to
previous
and next
will throw a
QueryOffEndException
when no data record is found, which is
consistent with the Progress FIND NEXT/PREV statement behavior.
On query off-end, the FIND NEXT/PREV statement will execute the action defined for the END-KEY condition (which defaults to UNDO, LEAVE, but can be overridden by an user-defined action). This behavior is only valid to following blocks:
This class also handles converted CAN-FIND statements.
Modifier and Type | Class and Description |
---|---|
private static class |
FindQuery.CanFind
Types of can-find lookups
|
P2JQuery.Parameter
Modifier and Type | Field and Description |
---|---|
private FindQuery.CanFind |
canFindMode
Mode of this query if used for CAN-FIND
|
private boolean |
readOnly
Flag indicating whether buffer is updated by query
|
cursor
closed, inverseSorting, parameterFilter
CURRENT, FIRST, LAST, NEXT, NONE, PREVIOUS, RETRIEVE_MODES, UNIQUE
Constructor and Description |
---|
FindQuery(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort)
Basic constructor which defaults record lock type to
LockType.SHARE . |
FindQuery(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
DataModelObject inverse)
Constructor which is used when joining to another table using a foreign
key.
|
FindQuery(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
DataModelObject inverse,
LockType lockType)
Constructor which is used when joining to another table using a foreign
key.
|
FindQuery(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
DataModelObject inverse,
java.lang.Object[] args)
Constructor which is used when joining to another table using a foreign
key.
|
FindQuery(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
DataModelObject inverse,
java.lang.Object[] args,
LockType lockType)
Constructor which is used when joining to another table using a foreign
key.
|
FindQuery(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
LockType lockType)
Constructor which sets an explicit, default, record lock type.
|
FindQuery(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
java.lang.Object[] args)
Constructor which defaults record lock type to
LockType.SHARE and accepts default substitution parameters. |
FindQuery(DataModelObject dmo,
java.lang.String where,
java.util.function.Supplier<logical> whereExpr,
java.lang.String sort,
java.lang.Object[] args,
LockType lockType)
Constructor which sets an explicit, default, record lock type and
accepts default substitution parameters.
|
Modifier and Type | Method and Description |
---|---|
private boolean |
canFindImpl(java.lang.Object[] values,
LockType lockType)
Indicate whether a record can be found with meets this query's criteria.
|
protected void |
handleExecuteException(LockUnavailableException exc)
Override the superclass' implementation to throw an exception
unconditionally when in read-only mode.
|
protected void |
handleExecuteException(PersistenceException exc)
Override the superclass' implementation to throw an exception
unconditionally when in read-only mode.
|
protected void |
handleExecuteException(ValidationException exc)
Override the superclass' implementation to throw an exception
unconditionally when in read-only mode.
|
logical |
hasAny()
Indicate whether a request to find the first result of this query would
succeed or fail.
|
logical |
hasAny(LockType lockType)
Indicate whether a request to find the first result of this query would
succeed or fail.
|
logical |
hasAny(java.lang.Object[] values)
Indicate whether a request to find the first result of this query would
succeed or fail.
|
logical |
hasAny(java.lang.Object[] values,
LockType lockType)
Indicate whether a request to find the first result of this query would
succeed or fail.
|
logical |
hasOne()
Indicate whether this query would produce a unique result.
|
logical |
hasOne(LockType lockType)
Indicate whether this query would produce a unique result.
|
logical |
hasOne(java.lang.Object[] values)
Indicate whether this query would produce a unique result.
|
logical |
hasOne(java.lang.Object[] values,
LockType lockType)
Indicate whether this query would produce a unique result.
|
protected void |
initializeBuffer()
Override the parent's method to do nothing.
|
protected boolean |
isIdOnly()
Override the parent's method to return
true if this is a CAN-FIND, else
delegate to the parent's implementation. |
protected void |
prepareBuffer()
Prepare buffer associated with this query for the query's execution.
|
protected void |
registerChangeListener()
This class doesn't need to register a change listener, so this method
does nothing.
|
FindQuery |
setHasAny()
Set this query's can-find mode to 'any', meaning can it find any record
which meets the query's criteria, regardless of duplicates.
|
FindQuery |
setHasOne()
Set this query's can-find mode to 'one', meaning can it find one and
only one record which meets the query's criteria.
|
private boolean |
testLock(Persistable dmo,
LockType lockType)
Test whether the specified lock type could be acquired for the given
DMO, but do not actually acquire the lock.
|
protected void |
updateBuffer(Persistable dmo,
LockType lockType,
boolean errorIfNull,
OffEnd offEnd)
Update the record buffer with the given DMO, applying the specified
lock type and error-if-null setting.
|
activateFirst, activateUnique, cleanup, close, close, current, current, execute, first, first, first, first, forceDynamicOperation, getArgs, getBreakValue, getBuffer, getCurrentArgs, getHelper, getJoin, getLockType, getOffEnd, getOffEndListeners, getOriginalWhere, getRecordBuffers, getRow, getSortPhrase, getTableCount, hasWhereExpression, indexInformation, initialize, initialize, initialize, initialize, initialize, initialize, initialize, initialize, initialize, initialize, initialize, initialize, initialize, initialize, initialize, initialize, last, last, last, last, load, makeAdaptiveServerJoinComponent, makePreselectServerJoinComponent, next, next, next, next, peekFirst, peekLast, peekNext, peekPrevious, previous, previous, previous, previous, recordBuffers, registerRecordChangeListeners, releaseBuffers, reset, setFullRecords, setLenientOffEnd, setReferenceRecord, setResults, setUnknownRecord, stateChanged, unique, unique, unique, unique
_isOffEnd, backward, backward, currentRow, currentRowImpl, forward, forward, incrementMoves, isNativelyPreselect, isPreselect, isScrolling, open, reposition, reposition, repositionByID, repositionByID, resetScrolling, setScrolling, size, verifyScrolling
accumulate, addAccumulator, addAccumulator, addBuffer, addBuffer, addRepositionListener, afterReposition, bufferHandle, bufferHandle, bufferHandle, bufferHandle, bufferHandle, changeForwardOnly, changeForwardOnly, deleteResultListEntry, deleteResultListEntry, exclude, forwardOnly, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, 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, getReferencedBuffers, hasAccumulators, include, indexInformation, indexInformation, isBrowsed, isErrorIfNull, isFetchOnReposition, isLastOfBreakGroup, isNewBreakGroup, isOffEnd, isOpen, isRepositionNotificationActive, isSkipDeletedRecord, isStandalone, loadRowAtCursor, notifyRepositionListeners, numBuffers, numResults, numResults, optimize, prepare, prepare, prepareFetch, prepareString, preprocessSubstitutionArguments, queryBackward, queryBackward, queryClose, queryForward, queryForward, queryOpen, queryReposition, queryReposition, queryRepositionByID, removeRepositionListener, setBrowsed, setBuffers, setBuffers, setErrorIfNull, setExternalBuffers, setFetchOnReposition, setParameterFilter, setSkipDeletedRecord, setStandalone, validateSubstitutionArguments
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getReferencedBuffers, setErrorIfNull
_isOffEnd, addAccumulator, addAccumulator, addBuffer, addBuffer, addRepositionListener, backward, backward, bufferHandle, bufferHandle, bufferHandle, bufferHandle, bufferHandle, changeForwardOnly, changeForwardOnly, currentRow, currentRowImpl, deleteResultListEntry, deleteResultListEntry, exclude, forward, forward, forwardOnly, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, getCurrent, 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, include, indexInformation, indexInformation, isBrowsed, isFetchOnReposition, isNativelyPreselect, isOffEnd, isOpen, isPreselect, isScrolling, isSkipDeletedRecord, isStandalone, notifyRepositionListeners, numBuffers, open, optimize, prepare, prepare, prepareString, queryBackward, queryBackward, queryClose, queryForward, queryForward, queryOpen, queryReposition, queryReposition, queryRepositionByID, removeRepositionListener, reposition, reposition, repositionByID, repositionByID, setBrowsed, setBuffers, setBuffers, setExternalBuffers, setFetchOnReposition, setParameterFilter, setScrolling, setSkipDeletedRecord, setStandalone, size
private FindQuery.CanFind canFindMode
private boolean readOnly
public FindQuery(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort)
LockType.SHARE
.dmo
- Data model object which determines the record buffer into which
records are retrieved.where
- Where clause, using HQL syntax. May be null
.whereExpr
- Client-side where clause expression. May be null
.sort
- Order by clause, using HQL syntax. May be null
only if query is to be navigated only using one of the
unique
method variants.public FindQuery(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, DataModelObject inverse)
LockType.SHARE
.dmo
- Data model object which determines the record buffer into which
records are retrieved.where
- Where clause, using HQL syntax. May be null
.whereExpr
- Client-side where clause expression. May be null
.sort
- Order by clause, using HQL syntax. May be null
only if query is to be navigated only using one of the
unique
method variants.inverse
- DMO to which this query should join via a foreign relation.
May be null
.public FindQuery(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, java.lang.Object[] args)
LockType.SHARE
and accepts default substitution parameters.dmo
- Data model object which determines the record buffer into which
records are retrieved.where
- Where clause, using HQL syntax. May be null
.whereExpr
- Client-side where clause expression. May be null
.sort
- Order by clause, using HQL syntax. May be null
only if query is to be navigated only using one of the
unique
method variants.args
- Substitution parameters for HQL queries. These will be used
if not overridden by a record retrieval method.java.lang.IllegalArgumentException
- if any substitution argument provided is not of a supported
type.public FindQuery(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, DataModelObject inverse, java.lang.Object[] args)
LockType.SHARE
and
accepts default substitution parameters.dmo
- Data model object which determines the record buffer into which
records are retrieved.where
- Where clause, using HQL syntax. May be null
.whereExpr
- Client-side where clause expression. May be null
.sort
- Order by clause, using HQL syntax. May be null
only if query is to be navigated only using one of the
unique
method variants.inverse
- DMO to which this query should join via a foreign relation.
May be null
.args
- Substitution parameters for HQL queries. These will be used
if not overridden by a record retrieval method.java.lang.IllegalArgumentException
- if any substitution argument provided is not of a supported
type.public FindQuery(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, LockType lockType)
dmo
- Data model object which determines the record buffer into which
records are retrieved.where
- Where clause, using HQL syntax. May be null
.whereExpr
- Client-side where clause expression. May be null
.sort
- Order by clause, using HQL syntax. May be null
only if query is to be navigated only using one of the
unique
method variants.lockType
- Lock type to apply to records retrieved, if not overridden by
a record retrieval method.public FindQuery(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, DataModelObject inverse, LockType lockType)
dmo
- Data model object which determines the record buffer into which
records are retrieved.where
- Where clause, using HQL syntax. May be null
.whereExpr
- Client-side where clause expression. May be null
.sort
- Order by clause, using HQL syntax. May be null
only if query is to be navigated only using one of the
unique
method variants.inverse
- DMO to which this query should join via a foreign relation.
May be null
.lockType
- Lock type to apply to records retrieved, if not overridden by
a record retrieval method.public FindQuery(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, java.lang.Object[] args, LockType lockType)
dmo
- Data model object which determines the record buffer into which
records are retrieved.where
- Where clause, using HQL syntax. May be null
.whereExpr
- Client-side where clause expression. May be null
.sort
- Order by clause, using HQL syntax. May be null
only if query is to be navigated only using one of the
unique
method variants.args
- Substitution parameters for HQL queries. These will be used
if not overridden by a record retrieval method.lockType
- Lock type to apply to records retrieved, if not overridden by
a record retrieval method.java.lang.IllegalArgumentException
- if any substitution argument provided is not of a supported
type.public FindQuery(DataModelObject dmo, java.lang.String where, java.util.function.Supplier<logical> whereExpr, java.lang.String sort, DataModelObject inverse, java.lang.Object[] args, LockType lockType)
dmo
- Data model object which determines the record buffer into which
records are retrieved.where
- Where clause, using HQL syntax. May be null
.whereExpr
- Client-side where clause expression. May be null
.sort
- Order by clause, using HQL syntax. May be null
only if query is to be navigated only using one of the
unique
method variants.inverse
- DMO to which this query should join via a foreign relation.
May be null
.args
- Substitution parameters for HQL queries. These will be used
if not overridden by a record retrieval method.lockType
- Lock type to apply to records retrieved, if not overridden by
a record retrieval method.java.lang.IllegalArgumentException
- if any substitution argument provided is not of a supported
type.public FindQuery setHasAny()
public FindQuery setHasOne()
public logical hasAny()
Default substitution arguments and a lock type of NONE
are
used for this test.
hasAny
in interface P2JQuery
hasAny
in class AbstractQuery
true
if the first record exists, else
false
.public logical hasAny(java.lang.Object[] values)
The specified substitution arguments and a lock type of
NONE
are used for this test.
hasAny
in interface P2JQuery
hasAny
in class AbstractQuery
values
- Query substitution parameters.true
if the first record exists, else
false
.public logical hasAny(LockType lockType)
Default substitution arguments and the specified lock type are used for this test.
hasAny
in interface P2JQuery
hasAny
in class AbstractQuery
lockType
- Lock type for the query. This lock is not actually acquired,
only tested for availability.true
if the first record exists, else
false
.public logical hasAny(java.lang.Object[] values, LockType lockType)
The specified substitution arguments and lock type are used for this test.
hasAny
in interface P2JQuery
hasAny
in class AbstractQuery
values
- Query substitution parameters.lockType
- Lock type for the query. This lock is not actually acquired,
only tested for availability.true
if the first record exists, else
false
.public logical hasOne()
Default substitution arguments and a lock type of NONE
are
used for this test.
hasOne
in interface P2JQuery
hasOne
in class AbstractQuery
true
if any record matching the query's criteria
exists, else false
.public logical hasOne(java.lang.Object[] values)
The specified substitution arguments and a lock type of
NONE
are used for this test.
hasOne
in interface P2JQuery
hasOne
in class AbstractQuery
values
- Query substitution parameters.true
if any record matching the query's criteria
exists, else false
.public logical hasOne(LockType lockType)
Default substitution arguments and the specified lock type are used for this test.
hasOne
in interface P2JQuery
hasOne
in class AbstractQuery
lockType
- Lock type for the query. This lock is not actually acquired,
only tested for availability.true
if any record matching the query's criteria
exists, else false
.public logical hasOne(java.lang.Object[] values, LockType lockType)
The specified substitution arguments and lock type are used for this test.
hasOne
in interface P2JQuery
hasOne
in class AbstractQuery
values
- Query substitution parameters.lockType
- Lock type for the query. This lock is not actually acquired,
only tested for availability.true
if any record matching the query's criteria
exists, else false
.protected void registerChangeListener()
registerChangeListener
in class RandomAccessQuery
protected void initializeBuffer()
initializeBuffer
in class RandomAccessQuery
protected boolean isIdOnly()
true
if this is a CAN-FIND, else
delegate to the parent's implementation.isIdOnly
in class RandomAccessQuery
true
to produce a projection query, else false
.protected void prepareBuffer() throws ValidationException
prepareBuffer
in class RandomAccessQuery
ValidationException
- if the parent's implementation is invoked and a buffer flush
triggers a validation error for the record currently stored in
the buffer.protected void updateBuffer(Persistable dmo, LockType lockType, boolean errorIfNull, OffEnd offEnd)
dmo
is null.updateBuffer
in class RandomAccessQuery
dmo
- Record to be stored in buffer.lockType
- Lock type associated with the record, which will be remembered
by the buffer.errorIfNull
- If true
, setting a null
value as the
current record in an underlying buffer will raise an error
condition (if not in silent error mode); if false
,
this action will raise an end condition instead.offEnd
- Enum indicating whether query is off-end, and if so, in which
direction.protected void handleExecuteException(LockUnavailableException exc)
When the query is not in read-only mode, handling is delegated to the superclass' implementation.
handleExecuteException
in class RandomAccessQuery
exc
- Cause exception.protected void handleExecuteException(ValidationException exc)
When the query is not in read-only mode, handling is delegated to the superclass' implementation.
handleExecuteException
in class RandomAccessQuery
exc
- Cause exception.protected void handleExecuteException(PersistenceException exc)
When the query is not in read-only mode, handling is delegated to the superclass' implementation.
handleExecuteException
in class RandomAccessQuery
exc
- Cause exception.private boolean canFindImpl(java.lang.Object[] values, LockType lockType)
true
if any record can be found which meets the query's
criteria, regardless of duplicates. If no such record is found, return
false
.true
if one and only one record can be found which meets
the query's criteria. If no such record is found, or if more than one such
record is found, return false
.values
- Query substitution parameterslockType
- Lock type to use when performing test. Lock is not actually acquired, only tested.private boolean testLock(Persistable dmo, LockType lockType)
Note: because this method does not actually acquire the lock, it is
not a reliable test, since another context could easily acquire the
target lock after this method returns true
, but before any
further action is taken on that information in the current context.
dmo
- DMO for which the lock test should occur.lockType
- Lock type to test.true
if the lock could be acquired at the moment
of the test, else false
.