org.mongodb.morphia
Interface AdvancedDatastore

All Superinterfaces:
Datastore
All Known Implementing Classes:
DatastoreImpl

public interface AdvancedDatastore
extends Datastore

This interface exposes advanced Datastore features, like interacting with DBObject and low-level options. It implements matching methods from the Datastore interface but with a specified kind (collection name), or raw types (DBObject).

Author:
ScottHernandez

Method Summary
<T> Query<T>
createQuery(Class<T> kind, DBObject q)
           
<T> Query<T>
createQuery(String kind, Class<T> clazz)
           
<T> Query<T>
createQuery(String kind, Class<T> clazz, DBObject q)
           
<T,V> DBRef
createRef(Class<T> clazz, V id)
          Creates a reference to the entity (using the current DB -can be null-, the collectionName, and id)
<T> DBRef
createRef(T entity)
          Creates a reference to the entity (using the current DB -can be null-, the collectionName, and id)
<T> UpdateOperations<T>
createUpdateOperations(Class<T> kind, DBObject ops)
           
<T,V> WriteResult
delete(String kind, Class<T> clazz, V id)
          Deletes an entity of the given type T, with the given id, from the collection with the name in the kind param.
<T,V> WriteResult
delete(String kind, Class<T> clazz, V id, WriteConcern wc)
          Deletes an entity of the given type T, with the given id, from the collection with the name in the kind param.
<T> void
ensureIndex(String collName, Class<T> clazz, String fields)
          Ensures (creating if necessary) the index including the field(s) + directions on the given collection name; eg fields = "field1, -field2" ({field1:1, field2:-1})
<T> void
ensureIndex(String collName, Class<T> clazz, String name, String fields, boolean unique, boolean dropDupsOnCreate)
          Ensures (creating if necessary) the index including the field(s) + directions on the given collection name; eg fields = "field1, -field2" ({field1:1, field2:-1})
<T> void
ensureIndexes(String collName, Class<T> clazz)
          Ensures (creating if necessary) the indexes found during class mapping (using @Indexed, @Indexes) on the given collection name.
<T> void
ensureIndexes(String collName, Class<T> clazz, boolean background)
          Ensures (creating if necessary) the indexes found during class mapping (using @Indexed, @Indexes) on the given collection name, possibly in the background
 Key<?> exists(Object keyOrEntity, ReadPreference readPreference)
           
<T> Query<T>
find(String kind, Class<T> clazz)
           
<T,V> Query<T>
find(String kind, Class<T> clazz, String property, V value, int offset, int size)
           
<T> T
get(Class<T> clazz, DBRef ref)
          Find the given entity (by collectionName/id);
<T,V> T
get(String kind, Class<T> clazz, V id)
           
 long getCount(String kind)
          Gets the count this kind
 DBDecoderFactory getDecoderFact()
           
<T> Iterable<Key<T>>
insert(Iterable<T> entities, WriteConcern wc)
           
<T> Iterable<Key<T>>
insert(String kind, Iterable<T> entities)
           
<T> Iterable<Key<T>>
insert(String kind, Iterable<T> entities, WriteConcern wc)
           
<T> Key<T>
insert(String kind, T entity)
           
<T> Iterable<Key<T>>
insert(T... entities)
           
<T> Key<T>
insert(T entity)
           
<T> Key<T>
insert(T entity, WriteConcern wc)
           
<T> Query<T>
queryByExample(String kind, T example)
          Returns a new query based on the example object
<T> Key<T>
save(String kind, T entity)
           
<T> Key<T>
save(String kind, T entity, WriteConcern wc)
           
 DBDecoderFactory setDecoderFact(DBDecoderFactory fact)
           
 
Methods inherited from interface org.mongodb.morphia.Datastore
createAggregation, createQuery, createUpdateOperations, delete, delete, delete, delete, delete, delete, ensureCaps, ensureIndex, ensureIndex, ensureIndexes, ensureIndexes, ensureIndexes, ensureIndexes, exists, find, find, find, findAndDelete, findAndModify, findAndModify, findAndModify, get, get, get, getByKey, getByKeys, getByKeys, getCollection, getCount, getCount, getCount, getDB, getDefaultWriteConcern, getKey, getMongo, getQueryFactory, mapReduce, mapReduce, merge, merge, queryByExample, save, save, save, save, save, setDefaultWriteConcern, setQueryFactory, update, update, update, update, update, updateFirst, updateFirst, updateFirst, updateFirst
 

Method Detail

exists

Key<?> exists(Object keyOrEntity,
              ReadPreference readPreference)
Parameters:
readPreference - Uses the supplied ReadPreference for the check. If readPreference is null the preference is taken from the annotation or uses the default preference.
See Also:
Datastore.exists(Object)

createRef

<T,V> DBRef createRef(Class<T> clazz,
                      V id)
Creates a reference to the entity (using the current DB -can be null-, the collectionName, and id)


createRef

<T> DBRef createRef(T entity)
Creates a reference to the entity (using the current DB -can be null-, the collectionName, and id)


get

<T> T get(Class<T> clazz,
          DBRef ref)
Find the given entity (by collectionName/id);


getCount

long getCount(String kind)
Gets the count this kind


get

<T,V> T get(String kind,
            Class<T> clazz,
            V id)

find

<T> Query<T> find(String kind,
                  Class<T> clazz)

find

<T,V> Query<T> find(String kind,
                    Class<T> clazz,
                    String property,
                    V value,
                    int offset,
                    int size)

save

<T> Key<T> save(String kind,
                T entity)

save

<T> Key<T> save(String kind,
                T entity,
                WriteConcern wc)

delete

<T,V> WriteResult delete(String kind,
                         Class<T> clazz,
                         V id)
Deletes an entity of the given type T, with the given id, from the collection with the name in the kind param. Validates the id, checking it's the correct type for an ID for entities of type T. The entity type clazz is used only for validation, not for filtering, therefore if you have entities of different types in the same collection (kind), this method will delete any entity with the given id, regardless of its type.

Type Parameters:
T - the entity type
V - is the type of the ID, for example ObjectId
Parameters:
kind - the collection name
clazz - the Class of the entity to delete
id - the value of the ID
Returns:
the result of this delete operation.

delete

<T,V> WriteResult delete(String kind,
                         Class<T> clazz,
                         V id,
                         WriteConcern wc)
Deletes an entity of the given type T, with the given id, from the collection with the name in the kind param. Validates the id, checking it's the correct type for an ID for entities of type T. The entity type clazz is used only for validation, not for filtering, therefore if you have entities of different types in the same collection (kind), this method will delete any entity with the given id, regardless of its type.

Type Parameters:
T - the entity type
V - is the type of the ID, for example ObjectId
Parameters:
kind - the collection name
clazz - the Class of the entity to delete
id - the value of the ID
wc - the WriteConcern for this operation
Returns:
the result of this delete operation.

insert

<T> Key<T> insert(String kind,
                  T entity)

insert

<T> Key<T> insert(T entity)

insert

<T> Key<T> insert(T entity,
                  WriteConcern wc)

insert

<T> Iterable<Key<T>> insert(T... entities)

insert

<T> Iterable<Key<T>> insert(Iterable<T> entities,
                            WriteConcern wc)

insert

<T> Iterable<Key<T>> insert(String kind,
                            Iterable<T> entities)

insert

<T> Iterable<Key<T>> insert(String kind,
                            Iterable<T> entities,
                            WriteConcern wc)

createQuery

<T> Query<T> createQuery(String kind,
                         Class<T> clazz)
Parameters:
kind - the name of the collection that should be queried
clazz - the class of objects to be returned
Returns:
Query for the specified class clazz

createQuery

<T> Query<T> createQuery(Class<T> kind,
                         DBObject q)
Parameters:
kind - the class of objects to be returned
q - the query which will be passed to a QueryFactory
Returns:
Query for the specified class clazz

createQuery

<T> Query<T> createQuery(String kind,
                         Class<T> clazz,
                         DBObject q)

queryByExample

<T> Query<T> queryByExample(String kind,
                            T example)
Returns a new query based on the example object


createUpdateOperations

<T> UpdateOperations<T> createUpdateOperations(Class<T> kind,
                                               DBObject ops)

setDecoderFact

DBDecoderFactory setDecoderFact(DBDecoderFactory fact)

getDecoderFact

DBDecoderFactory getDecoderFact()

ensureIndexes

<T> void ensureIndexes(String collName,
                       Class<T> clazz)
Ensures (creating if necessary) the indexes found during class mapping (using @Indexed, @Indexes) on the given collection name.


ensureIndexes

<T> void ensureIndexes(String collName,
                       Class<T> clazz,
                       boolean background)
Ensures (creating if necessary) the indexes found during class mapping (using @Indexed, @Indexes) on the given collection name, possibly in the background


ensureIndex

<T> void ensureIndex(String collName,
                     Class<T> clazz,
                     String fields)
Ensures (creating if necessary) the index including the field(s) + directions on the given collection name; eg fields = "field1, -field2" ({field1:1, field2:-1})


ensureIndex

<T> void ensureIndex(String collName,
                     Class<T> clazz,
                     String name,
                     String fields,
                     boolean unique,
                     boolean dropDupsOnCreate)
Ensures (creating if necessary) the index including the field(s) + directions on the given collection name; eg fields = "field1, -field2" ({field1:1, field2:-1})