T
- The java type to query againstpublic interface Query<T> extends QueryResults<T>, Cloneable
Modifier and Type | Method and Description |
---|---|
CriteriaContainer |
and(Criteria... criteria) |
Query<T> |
batchSize(int value)
Batch-size of the fetched result (cursor).
|
Query<T> |
cloneQuery()
Creates and returns a copy of this
Query . |
Query<T> |
comment(String comment)
This makes it possible to attach a comment to a query.
|
FieldEnd<? extends CriteriaContainerImpl> |
criteria(String field)
Criteria builder interface
|
Query<T> |
disableCursorTimeout()
Disables cursor timeout on server.
|
Query<T> |
disableSnapshotMode()
Disable snapshotted mode (default mode).
|
Query<T> |
disableValidation()
Turns off validation (for all calls made after)
|
Query<T> |
enableCursorTimeout()
Enables cursor timeout on server.
|
Query<T> |
enableSnapshotMode()
Enabled snapshotted mode where duplicate results (which may be updated during the lifetime of the cursor) will not be returned.
|
Query<T> |
enableValidation()
Turns on validation (for all calls made after); by default validation is on
|
Map<String,Object> |
explain()
Provides information on the query plan.
|
FieldEnd<? extends Query<T>> |
field(String field)
Fluent query interface:
createQuery(Ent.class).field("count").greaterThan(7)... |
Query<T> |
filter(String condition,
Object value)
Create a filter based on the specified condition and value.
|
int |
getBatchSize()
Returns the batch size
|
DBCollection |
getCollection()
Returns the
DBCollection of the Query . |
Class<T> |
getEntityClass()
Returns the entity
Class . |
DBObject |
getFieldsObject()
Returns the Mongo fields
DBObject . |
int |
getLimit()
Returns the limit
|
int |
getOffset()
Returns the offset.
|
DBObject |
getQueryObject()
Returns the Mongo query
DBObject . |
DBObject |
getSortObject()
Returns the Mongo sort
DBObject . |
Query<T> |
hintIndex(String idxName)
Hints as to which index should be used.
|
Query<T> |
limit(int value)
Limit the fetched result set to a certain number of values.
|
Query<T> |
lowerIndexBound(DBObject lowerBound)
Specify the inclusive lower bound for a specific index in order to constrain the results of this query.
|
Query<T> |
maxScan(int value)
Constrains the query to only scan the specified number of documents when fulfilling the query.
|
Query<T> |
maxTime(long maxTime,
TimeUnit maxTimeUnit)
Specifies a time limit for executing the query.
|
Query<T> |
offset(int value)
Starts the query results at a particular zero-based offset.
|
CriteriaContainer |
or(Criteria... criteria) |
Query<T> |
order(String condition)
Sorts based on a property (defines return order).
|
Query<T> |
queryNonPrimary()
Deprecated.
use #useReadPreference(ReadPreference) instead
|
Query<T> |
queryPrimaryOnly()
Deprecated.
use #useReadPreference(ReadPreference)
|
Query<T> |
retrievedFields(boolean include,
String... fields)
Limits the fields retrieved
|
Query<T> |
retrieveKnownFields()
Limits the fields retrieved to those of the query type -- dangerous with interfaces and abstract classes
|
Query<T> |
returnKey()
Only return the index field or fields for the results of the query.
|
Query<T> |
search(String text)
Perform a text search on the content of the fields indexed with a text index..
|
Query<T> |
search(String text,
String language)
Perform a text search on the content of the fields indexed with a text index..
|
String |
toString()
Generates a string that consistently and uniquely specifies this query.
|
Query<T> |
upperIndexBound(DBObject upperBound)
Specify the exclusive upper bound for a specific index in order to constrain the results of this query.
|
Query<T> |
useReadPreference(ReadPreference readPref)
Route query ReadPreference
|
Query<T> |
where(CodeWScope js)
Limit the query using this javascript block; only one per query
|
Query<T> |
where(String js)
Limit the query using this javascript block; only one per query
|
CriteriaContainer and(Criteria... criteria)
Query<T> batchSize(int value)
value
- must be >= 0. A value of 0 indicates the server default.Query<T> comment(String comment)
comment
- the comment to addFieldEnd<? extends CriteriaContainerImpl> criteria(String field)
Query<T> disableSnapshotMode()
Query<T> enableSnapshotMode()
Query<T> enableValidation()
Map<String,Object> explain()
FieldEnd<? extends Query<T>> field(String field)
createQuery(Ent.class).field("count").greaterThan(7)...
Query<T> filter(String condition, Object value)
Create a filter based on the specified condition and value.
Note: Property is in the form of "name op" ("age >").
Valid operators are ["=", "==","!=", "<>", ">", "<", ">=", "<=", "in", "nin", "all", "size", "exists"]
Examples:
filter("yearsOfOperation >", 5)
filter("rooms.maxBeds >=", 2)
filter("rooms.bathrooms exists", 1)
filter("stars in", new Long[]{3, 4}) //3 and 4 stars (midrange?)
filter("quantity mod", new Long[]{4, 0}) // customers ordered in packs of 4)
filter("age >=", age)
filter("age =", age)
filter("age", age)
(if no operator, = is assumed)filter("age !=",
age)
filter("age in", ageList)
filter("customers.loyaltyYears in", yearsList)
You can filter on id properties if this query is restricted to a Class
int getBatchSize()
batchSize(int)
DBCollection getCollection()
DBCollection
of the Query
.int getLimit()
limit(int)
int getOffset()
offset(int)
Query<T> limit(int value)
value
- must be >= 0. A value of 0 indicates no limit. For values < 0, use batchSize(int)
which is the preferred
methodQuery<T> lowerIndexBound(DBObject lowerBound)
Specify the inclusive lower bound for a specific index in order to constrain the results of this query.
You can chain key/value pairs to build a constraint for a compound index. For instance: query.lowerIndexBound(new
BasicDBObject("a", 1).append("b", 2));
to build a constraint on index {"a", "b"}
lowerBound
- The inclusive lower bound.Query<T> maxScan(int value)
value
- must be > 0. A value < 0 indicates no limitQuery<T> maxTime(long maxTime, TimeUnit maxTimeUnit)
maxTime
- must be > 0. A value < 0 indicates no limitmaxTimeUnit
- Query<T> offset(int value)
value
- must be >= 0CriteriaContainer or(Criteria... criteria)
Query<T> order(String condition)
Sorts based on a property (defines return order). Examples:
order("age")
order("-age")
(descending order)order("age, date")
order("age,-date")
(age ascending, date descending)Query<T> queryNonPrimary()
Query<T> queryPrimaryOnly()
ReadPreference.primary()
Query<T> retrieveKnownFields()
Query<T> retrievedFields(boolean include, String... fields)
Query<T> returnKey()
Query<T> search(String text)
text
- the text to search forQuery<T> search(String text, String language)
text
- the text to search forlanguage
- the language to use during the searchString toString()
Generates a string that consistently and uniquely specifies this query. There is no way to convert this string back into a query and there is no guarantee that the string will be consistent across versions.
In particular, this value is useful as a key for a simple memcache query cache.
Query<T> upperIndexBound(DBObject upperBound)
Specify the exclusive upper bound for a specific index in order to constrain the results of this query.
You can chain key/value pairs to build a constraint for a compound index. For instance: query.upperIndexBound(new
BasicDBObject("a", 1).append("b", 2));
to build a constraint on index {"a", "b"}
upperBound
- The exclusive upper bound.Query<T> useReadPreference(ReadPreference readPref)
Query<T> where(CodeWScope js)