play.modules.morphia
Class Model.MorphiaQuery

java.lang.Object
  extended by play.modules.morphia.Model.MorphiaQuery
Enclosing class:
Model

public static class Model.MorphiaQuery
extends Object


Constructor Summary
Model.MorphiaQuery(Class<? extends Model> clazz)
           
Model.MorphiaQuery(Class<? extends Model> clazz, DBCollection coll, Datastore ds)
           
Model.MorphiaQuery(Class<? extends Model> clazz, DBCollection coll, Datastore ds, int offset, int limit)
           
 
Method Summary
 Model _get()
           
<T extends Model>
CriteriaContainer
and(Criteria... criteria)
           
<T extends Model>
List<Key<T>>
asKeyList()
           
<T extends Model>
List<T>
asList()
           
 Long average(String field)
           
<T extends Model>
Model.MorphiaQuery
batchSize(int value)
           
 Model.MorphiaQuery clone()
           
 Map<String,Long> cloud(String field)
           
 DBCollection col()
           
 long count()
          Alias of countAll()
 long countAll()
           
<T extends Model>
FieldEnd<? extends CriteriaContainerImpl>
criteria(String field)
           
 long delete()
           
<T extends Model>
Model.MorphiaQuery
disableCursorTimeout()
           
<T extends Model>
Model.MorphiaQuery
disableSnapshotMode()
           
<T extends Model>
Model.MorphiaQuery
disableTimeout()
          Deprecated. 
<T extends Model>
Model.MorphiaQuery
disableValidation()
           
 Set<?> distinct(String key)
           
static Datastore ds()
           
<T extends Model>
Model.MorphiaQuery
enableCursorTimeout()
           
<T extends Model>
Model.MorphiaQuery
enableSnapshotMode()
           
<T extends Model>
Model.MorphiaQuery
enableTimeout()
          Deprecated. 
<T extends Model>
Model.MorphiaQuery
enableValidation()
           
<T extends Model>
Iterable<T>
fetch()
           
<T extends Model>
List<T>
fetch(int max)
          Retrieve results of the query
<T extends Model>
List<T>
fetch(int page, int length)
          Retrieve a page of result
<T extends Model>
List<T>
fetchAll()
          Retrieve all results of the query This is a correspondence to JPAQuery's fetch(), which however, used as another method signature of Morphia Query
<T extends Model>
Iterable<T>
fetchEmptyEntities()
           
<T extends Model>
Iterable<Key<T>>
fetchKeys()
           
<T extends Model>
FieldEnd<? extends Query<T>>
field(String field)
           
<T extends Model>
Model.MorphiaQuery
filter(String condition, Object value)
           
 Model.MorphiaQuery findBy(String query, Object... params)
          Used to simulate JPA.find("byXXAndYY", ...);
<T> T
first()
           
<T> Model.MorphiaQuery
from(int position)
          Set the position to start
<T extends Model>
T
get()
           
 Class<? extends Model> getEntityClass()
           
<T extends Model>
Key<T>
getKey()
           
 Query<? extends Model> getMorphiaQuery()
           
 DBObject getQueryObject()
           
 List<CommandResult> group(String groupKeys, DBObject initial, String reduce, String finalize)
           
 AggregationResult groupAverage(String field, String... groupKeys)
           
 AggregationResult groupCount(String field, String... groupKeys)
           
 AggregationResult groupMax(String field, String... groupKeys)
           
 AggregationResult groupMin(String field, String... groupKeys)
           
 AggregationResult groupSum(String field, String... groupKeys)
           
<T extends Model>
Model.MorphiaQuery
hintIndex(String idxName)
           
<T extends Model>
Iterator<T>
iterator()
           
<T extends Model>
Model.MorphiaQuery
limit(int value)
           
 Long max(String maxField)
           
 Long min(String minField)
           
<T extends Model>
Model.MorphiaQuery
offset(int value)
           
<T extends Model>
CriteriaContainer
or(Criteria... criteria)
           
<T extends Model>
Model.MorphiaQuery
order(String condition)
           
<T extends Model>
Model.MorphiaQuery
queryNonPrimary()
           
<T extends Model>
Model.MorphiaQuery
queryPrimaryOnly()
           
<T extends Model>
Model.MorphiaQuery
retrievedFields(boolean include, String... fields)
           
<T extends Model>
Model.MorphiaQuery
skip(int value)
          Deprecated. 
 Long sum(String field)
           
 String toString()
           
<T extends Model>
Model.MorphiaQuery
where(CodeWScope js)
           
<T extends Model>
Model.MorphiaQuery
where(String js)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Model.MorphiaQuery

public Model.MorphiaQuery(Class<? extends Model> clazz)

Model.MorphiaQuery

public Model.MorphiaQuery(Class<? extends Model> clazz,
                          DBCollection coll,
                          Datastore ds)

Model.MorphiaQuery

public Model.MorphiaQuery(Class<? extends Model> clazz,
                          DBCollection coll,
                          Datastore ds,
                          int offset,
                          int limit)
Method Detail

ds

public static Datastore ds()

getMorphiaQuery

public Query<? extends Model> getMorphiaQuery()

getQueryObject

public DBObject getQueryObject()

col

public DBCollection col()

delete

public long delete()

count

public long count()
Alias of countAll()

Returns:

findBy

public Model.MorphiaQuery findBy(String query,
                                 Object... params)
Used to simulate JPA.find("byXXAndYY", ...);

Parameters:
query - could be either "Key1[AndKey2[AndKey3]]" or "byKey1[AndKey2[AndKey3]]" or "key1 key2 ..."
params - the number of params should either be exactly one or the number match the key number
Returns:

toString

public String toString()
Overrides:
toString in class Object

first

public <T> T first()

from

public <T> Model.MorphiaQuery from(int position)
Set the position to start

Parameters:
position - Position of the first element
Returns:
A new query

fetchAll

public <T extends Model> List<T> fetchAll()
Retrieve all results of the query This is a correspondence to JPAQuery's fetch(), which however, used as another method signature of Morphia Query

Returns:
A list of entities

fetch

public <T extends Model> List<T> fetch(int max)
Retrieve results of the query

Parameters:
max - Max results to fetch
Returns:
A list of entities

fetch

public <T extends Model> List<T> fetch(int page,
                                       int length)
Retrieve a page of result

Parameters:
page - Page number (start at 1)
length - (page length)
Returns:
a list of entities

_get

public Model _get()

get

public <T extends Model> T get()

filter

public <T extends Model> Model.MorphiaQuery filter(String condition,
                                                   Object value)

getKey

public <T extends Model> Key<T> getKey()

iterator

public <T extends Model> Iterator<T> iterator()

asList

public <T extends Model> List<T> asList()

asKeyList

public <T extends Model> List<Key<T>> asKeyList()

fetch

public <T extends Model> Iterable<T> fetch()

distinct

public Set<?> distinct(String key)

cloud

public Map<String,Long> cloud(String field)

group

public List<CommandResult> group(String groupKeys,
                                 DBObject initial,
                                 String reduce,
                                 String finalize)
Parameters:
groupKeys - could be either "f1Andf2.." or "f1 f2" or "f1,f2"
Returns:

groupMax

public AggregationResult groupMax(String field,
                                  String... groupKeys)

max

public Long max(String maxField)

groupMin

public AggregationResult groupMin(String field,
                                  String... groupKeys)

min

public Long min(String minField)

groupAverage

public AggregationResult groupAverage(String field,
                                      String... groupKeys)

average

public Long average(String field)

groupSum

public AggregationResult groupSum(String field,
                                  String... groupKeys)

sum

public Long sum(String field)

groupCount

public AggregationResult groupCount(String field,
                                    String... groupKeys)

fetchEmptyEntities

public <T extends Model> Iterable<T> fetchEmptyEntities()

field

public <T extends Model> FieldEnd<? extends Query<T>> field(String field)

fetchKeys

public <T extends Model> Iterable<Key<T>> fetchKeys()

criteria

public <T extends Model> FieldEnd<? extends CriteriaContainerImpl> criteria(String field)

and

public <T extends Model> CriteriaContainer and(Criteria... criteria)

countAll

public long countAll()

or

public <T extends Model> CriteriaContainer or(Criteria... criteria)

where

public <T extends Model> Model.MorphiaQuery where(String js)

where

public <T extends Model> Model.MorphiaQuery where(CodeWScope js)

order

public <T extends Model> Model.MorphiaQuery order(String condition)

limit

public <T extends Model> Model.MorphiaQuery limit(int value)

batchSize

public <T extends Model> Model.MorphiaQuery batchSize(int value)

offset

public <T extends Model> Model.MorphiaQuery offset(int value)

skip

@Deprecated
public <T extends Model> Model.MorphiaQuery skip(int value)
Deprecated. 


enableValidation

public <T extends Model> Model.MorphiaQuery enableValidation()

disableValidation

public <T extends Model> Model.MorphiaQuery disableValidation()

hintIndex

public <T extends Model> Model.MorphiaQuery hintIndex(String idxName)

retrievedFields

public <T extends Model> Model.MorphiaQuery retrievedFields(boolean include,
                                                            String... fields)

enableSnapshotMode

public <T extends Model> Model.MorphiaQuery enableSnapshotMode()

disableSnapshotMode

public <T extends Model> Model.MorphiaQuery disableSnapshotMode()

queryNonPrimary

public <T extends Model> Model.MorphiaQuery queryNonPrimary()

queryPrimaryOnly

public <T extends Model> Model.MorphiaQuery queryPrimaryOnly()

disableTimeout

@Deprecated
public <T extends Model> Model.MorphiaQuery disableTimeout()
Deprecated. 


disableCursorTimeout

public <T extends Model> Model.MorphiaQuery disableCursorTimeout()

enableTimeout

@Deprecated
public <T extends Model> Model.MorphiaQuery enableTimeout()
Deprecated. 


enableCursorTimeout

public <T extends Model> Model.MorphiaQuery enableCursorTimeout()

getEntityClass

public Class<? extends Model> getEntityClass()

clone

public Model.MorphiaQuery clone()
Overrides:
clone in class Object


Copyright © 2012. All Rights Reserved.