|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Query<S extends Storable>
Supports complex retrieval and deletion of Storable objects.
Queries are immutable representations of an action – they do not
contain any Storable instances. The apparent mutators (with, et al) do not
actually modify the Query. Instead, they return another Query instance which
has the requested modification. To obtain an initial Query instance, call
one of the Storage query methods.
Query objects are usually compiled and cached, and the same instance can be re-used for future queries. This is possible because queries are immutable and naturally thread-safe.
| Method Summary | ||
|---|---|---|
|
after(T start)
Returns a query which fetches results for this query after a given starting point, which is useful for re-opening a cursor. |
|
Query<S> |
and(Filter<S> filter)
Returns a new query which has another filter logically "and"ed to this, potentially reducing the amount of
results. |
|
Query<S> |
and(String filter)
Returns a new query which has another filter logically "and"ed to this, potentially reducing the amount of
results. |
|
long |
count()
Returns a count of all results matched by this query. |
|
void |
deleteAll()
Deletes zero or more matching objects. |
|
void |
deleteOne()
Deletes one matching object. |
|
boolean |
equals(Object obj)
|
|
boolean |
exists()
Returns true if any results are matched by this query. |
|
Cursor<S> |
fetch()
Fetches results for this query. |
|
|
fetchAfter(T start)
Fetches results for this query after a given starting point, which is useful for re-opening a cursor. |
|
Cursor<S> |
fetchSlice(long from,
Long to)
Fetches a slice of results for this query, as defined by a numerical range. |
|
int |
getBlankParameterCount()
Returns the amount of blank parameters that need to be filled in. |
|
Filter<S> |
getFilter()
Returns the query's filter. |
|
FilterValues<S> |
getFilterValues()
Returns the query's filter values, which is null if filter has no parameters. |
|
Class<S> |
getStorableType()
Returns the specific type of Storable managed by this object. |
|
int |
hashCode()
|
|
S |
loadOne()
Attempts to load exactly one matching object. |
|
Query<S> |
not()
Returns a new query which produces all the results not supplied in this query. |
|
Query<S> |
or(Filter<S> filter)
Returns a new query which has another filter logically "or"ed to this, potentially increasing the amount of
results. |
|
Query<S> |
or(String filter)
Returns a new query which has another filter logically "or"ed to this, potentially increasing the amount of
results. |
|
Query<S> |
orderBy(String... properties)
Returns a copy of this query ordered by specific property values. |
|
Query<S> |
orderBy(String property)
Returns a copy of this query ordered by a specific property value. |
|
boolean |
printNative()
Print the native query to standard out, which is useful for performance analysis. |
|
boolean |
printNative(Appendable app)
Prints the native query to any appendable, which is useful for performance analysis. |
|
boolean |
printNative(Appendable app,
int indentLevel)
Prints the native query to any appendable, which is useful for performance analysis. |
|
boolean |
printPlan()
Prints the query excecution plan to standard out, which is useful for performance analysis. |
|
boolean |
printPlan(Appendable app)
Prints the query excecution plan to any appendable, which is useful for performance analysis. |
|
boolean |
printPlan(Appendable app,
int indentLevel)
Prints the query excecution plan to any appendable, which is useful for performance analysis. |
|
String |
toString()
Returns a description of the query filter and any other arguments. |
|
boolean |
tryDeleteOne()
Deletes zero or one matching objects. |
|
S |
tryLoadOne()
May return null if nothing found. |
|
Query<S> |
with(boolean value)
Returns a copy of this Query with the next blank parameter filled in. |
|
Query<S> |
with(byte value)
Returns a copy of this Query with the next blank parameter filled in. |
|
Query<S> |
with(char value)
Returns a copy of this Query with the next blank parameter filled in. |
|
Query<S> |
with(double value)
Returns a copy of this Query with the next blank parameter filled in. |
|
Query<S> |
with(float value)
Returns a copy of this Query with the next blank parameter filled in. |
|
Query<S> |
with(int value)
Returns a copy of this Query with the next blank parameter filled in. |
|
Query<S> |
with(long value)
Returns a copy of this Query with the next blank parameter filled in. |
|
Query<S> |
with(Object value)
Returns a copy of this Query with the next blank parameter filled in. |
|
Query<S> |
with(short value)
Returns a copy of this Query with the next blank parameter filled in. |
|
Query<S> |
withValues(Object... values)
Returns a copy of this Query with the next blank parameters filled in. |
|
| Method Detail |
|---|
Class<S> getStorableType()
Filter<S> getFilter()
FilterValues<S> getFilterValues()
int getBlankParameterCount()
Query<S> with(int value)
value - parameter value to fill in
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't matchQuery<S> with(long value)
value - parameter value to fill in
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't matchQuery<S> with(float value)
value - parameter value to fill in
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't matchQuery<S> with(double value)
value - parameter value to fill in
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't matchQuery<S> with(boolean value)
value - parameter value to fill in
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't matchQuery<S> with(char value)
value - parameter value to fill in
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't matchQuery<S> with(byte value)
value - parameter value to fill in
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't matchQuery<S> with(short value)
value - parameter value to fill in
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't matchQuery<S> with(Object value)
value - parameter value to fill in
IllegalStateException - if no blank parameters
IllegalArgumentException - if type doesn't matchQuery<S> withValues(Object... values)
values - parameter values to fill in; if null or empty, this
Query instance is returned
IllegalStateException - if no blank parameters or if too many
parameter values supplied
IllegalArgumentException - if any type doesn't match
Query<S> and(String filter)
throws FetchException
filter logically "and"ed to this, potentially reducing the amount of
results.
filter - query filter expression
FetchException - if storage layer throws an exception
IllegalStateException - if any blank parameters in this query, or
if this query is already guaranteed to fetch nothing
IllegalArgumentException - if filter is null
MalformedFilterException - if expression is malformed
UnsupportedOperationException - if given filter is unsupported by repository
Query<S> and(Filter<S> filter)
throws FetchException
filter logically "and"ed to this, potentially reducing the amount of
results.
filter - query filter
FetchException - if storage layer throws an exception
IllegalStateException - if any blank parameters in this query, or
if this query is already guaranteed to fetch nothing
IllegalArgumentException - if filter is null
UnsupportedOperationException - if given filter is unsupported by repository
Query<S> or(String filter)
throws FetchException
filter logically "or"ed to this, potentially increasing the amount of
results.
filter - query filter expression
FetchException - if storage layer throws an exception
IllegalStateException - if any blank parameters in this query, or
if this query is already guaranteed to fetch everything
IllegalArgumentException - if filter is null
MalformedFilterException - if expression is malformed
UnsupportedOperationException - if given filter is unsupported by repository
Query<S> or(Filter<S> filter)
throws FetchException
filter logically "or"ed to this, potentially increasing the amount of
results.
filter - query filter
FetchException - if storage layer throws an exception
IllegalStateException - if any blank parameters in this query, or
if this query is already guaranteed to fetch everything
IllegalArgumentException - if filter is null
UnsupportedOperationException - if given filter is unsupported by repository
Query<S> not()
throws FetchException
FetchException - if storage layer throws an exception
UnsupportedOperationException - if new query is unsupported by repository
Query<S> orderBy(String property)
throws FetchException
Note: Specification of ordering properties is not cumulative. Calling this method will first remove any previous ordering properties.
property - name of property to order by
FetchException - if storage layer throws an exception
IllegalArgumentException - if property is null or is not a member
of type S
UnsupportedOperationException - if given ordering, combined with
query filter, is unsupported by repository
Query<S> orderBy(String... properties)
throws FetchException
Note: Specification of ordering properties is not cumulative. Calling this method will first remove any previous ordering properties.
properties - names of properties to order by
FetchException - if storage layer throws an exception
IllegalArgumentException - if any property is null or is not a
member of type S
UnsupportedOperationException - if given ordering, combined with
query filter, is unsupported by repository
<T extends S> Query<S> after(T start)
throws FetchException
ordering. If not a total ordering, then query may start at an earlier
position.
Note: The returned query can be very expensive to fetch from repeatedly, if the query needs to perform a sort operation. Ideally, the query ordering should match the natural ordering of an index or key.
start - storable to attempt to start after; if null, this query is
returned
IllegalStateException - if any blank parameters in this query
FetchException - if storage layer throws an exception
Cursor<S> fetch()
throws FetchException
IllegalStateException - if any blank parameters in this query
FetchException - if storage layer throws an exceptionRepository.enterTransaction(IsolationLevel)
Cursor<S> fetchSlice(long from,
Long to)
throws FetchException
ordering in order for the slice results to be deterministic.
from - zero-based from record number, inclusiveto - optional zero-based to record number, exclusive
IllegalStateException - if any blank parameters in this query
IllegalArgumentException - if from is negative or if
from is more than to
FetchException - if storage layer throws an exception
<T extends S> Cursor<S> fetchAfter(T start)
throws FetchException
ordering. If not a total
ordering, then cursor may start at an earlier position.
Note: This method can be very expensive to call repeatedly, if the query needs to perform a sort operation. Ideally, the query ordering should match the natural ordering of an index or key.
Calling fetchAfter(s) is equivalent to calling after(s).fetch().
start - storable to attempt to start after; if null, fetch all results
IllegalStateException - if any blank parameters in this query
FetchException - if storage layer throws an exceptionRepository.enterTransaction(IsolationLevel),
after(T)
S loadOne()
throws FetchException
IllegalStateException - if any blank parameters in this query
FetchNoneException - if no matching record found
FetchMultipleException - if more than one matching record found
FetchException - if storage layer throws an exception
S tryLoadOne()
throws FetchException
IllegalStateException - if any blank parameters in this query
FetchMultipleException - if more than one matching record found
FetchException - if storage layer throws an exception
void deleteOne()
throws PersistException
IllegalStateException - if any blank parameters in this query
PersistNoneException - if no matching record found
PersistMultipleException - if more than one record matches
PersistException - if storage layer throws an exception
boolean tryDeleteOne()
throws PersistException
IllegalStateException - if any blank parameters in this query
PersistMultipleException - if more than one record matches
PersistException - if storage layer throws an exception
void deleteAll()
throws PersistException
IllegalStateException - if any blank parameters in this query
PersistException - if storage layer throws an exception
long count()
throws FetchException
IllegalStateException - if any blank parameters in this query
FetchException - if storage layer throws an exception
boolean exists()
throws FetchException
IllegalStateException - if any blank parameters in this query
FetchException - if storage layer throws an exceptionboolean printNative()
boolean printNative(Appendable app)
throws IOException
app - append results here
IOException
boolean printNative(Appendable app,
int indentLevel)
throws IOException
app - append results hereindentLevel - amount to indent text, zero for none
IOExceptionboolean printPlan()
boolean printPlan(Appendable app)
throws IOException
app - append results here
IOException
boolean printPlan(Appendable app,
int indentLevel)
throws IOException
app - append results hereindentLevel - amount to indent text, zero for none
IOExceptionint hashCode()
hashCode in class Objectboolean equals(Object obj)
equals in class ObjectString toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||