Spring Data MongoDB - Core

org.springframework.data.mongodb.core.query
Class Query

java.lang.Object
  extended by org.springframework.data.mongodb.core.query.Query
Direct Known Subclasses:
BasicQuery

public class Query
extends Object

Author:
Thomas Risberg, Oliver Gierke, Thomas Darimont

Constructor Summary
Query()
           
Query(Criteria criteria)
          Creates a new Query using the given Criteria.
 
Method Summary
 Query addCriteria(Criteria criteria)
          Adds the given Criteria to the current Query.
 boolean equals(Object obj)
           
 Field fields()
           
protected  List<Criteria> getCriteria()
           
 com.mongodb.DBObject getFieldsObject()
           
 String getHint()
           
 int getLimit()
          Get the maximum number of documents to be return.
 com.mongodb.DBObject getQueryObject()
           
 Set<Class<?>> getRestrictedTypes()
           
 int getSkip()
          Get the number of documents to skip.
 com.mongodb.DBObject getSortObject()
           
 int hashCode()
           
static boolean isRestrictedTypeKey(String key)
          Deprecated. don't call this method as the restricted type handling will undergo some significant changes going forward.
 Query limit(int limit)
          Limit the number of returned documents to limit.
static Query query(Criteria criteria)
          Static factory method to create a Query using the provided Criteria.
 Query restrict(Class<?> type, Class<?>... additionalTypes)
          Restricts the query to only return documents instances that are exactly of the given types.
 Query skip(int skip)
          Set number of documents to skip before returning results.
 String toString()
           
 Query with(Pageable pageable)
          Sets the given pagination information on the Query instance.
 Query with(Sort sort)
          Adds a Sort to the Query instance.
 Query withHint(String name)
          Configures the query to use the given hint when being executed.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Query

public Query()

Query

public Query(Criteria criteria)
Creates a new Query using the given Criteria.

Parameters:
criteria - must not be null.
Method Detail

query

public static Query query(Criteria criteria)
Static factory method to create a Query using the provided Criteria.

Parameters:
criteria - must not be null.
Returns:

addCriteria

public Query addCriteria(Criteria criteria)
Adds the given Criteria to the current Query.

Parameters:
criteria - must not be null.
Returns:

fields

public Field fields()

skip

public Query skip(int skip)
Set number of documents to skip before returning results.

Parameters:
skip -
Returns:

limit

public Query limit(int limit)
Limit the number of returned documents to limit.

Parameters:
limit -
Returns:

withHint

public Query withHint(String name)
Configures the query to use the given hint when being executed.

Parameters:
name - must not be null or empty.
Returns:

with

public Query with(Pageable pageable)
Sets the given pagination information on the Query instance. Will transparently set skip and limit as well as applying the Sort instance defined with the Pageable.

Parameters:
pageable -
Returns:

with

public Query with(Sort sort)
Adds a Sort to the Query instance.

Parameters:
sort -
Returns:

getRestrictedTypes

public Set<Class<?>> getRestrictedTypes()
Returns:
the restrictedTypes

restrict

public Query restrict(Class<?> type,
                      Class<?>... additionalTypes)
Restricts the query to only return documents instances that are exactly of the given types.

Parameters:
type - may not be null
additionalTypes - may not be null
Returns:

getQueryObject

public com.mongodb.DBObject getQueryObject()

getFieldsObject

public com.mongodb.DBObject getFieldsObject()

getSortObject

public com.mongodb.DBObject getSortObject()

getSkip

public int getSkip()
Get the number of documents to skip.

Returns:

getLimit

public int getLimit()
Get the maximum number of documents to be return.

Returns:

getHint

public String getHint()
Returns:

getCriteria

protected List<Criteria> getCriteria()

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isRestrictedTypeKey

@Deprecated
public static boolean isRestrictedTypeKey(String key)
Deprecated. don't call this method as the restricted type handling will undergo some significant changes going forward.

Returns whether the given key is the one used to hold the type restriction information.

Parameters:
key -
Returns:

Spring Data MongoDB - Core

Copyright © 2011-2013-2014 Pivotal. All Rights Reserved.