public interface AdvancedDatastore extends Datastore
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).| Modifier and Type | Method and Description |
|---|---|
<T> Query<T> |
createQuery(Class<T> clazz,
DBObject q) |
<T> Query<T> |
createQuery(String collection,
Class<T> clazz) |
<T> Query<T> |
createQuery(String collection,
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> type,
DBObject ops)
Creates an UpdateOperations instance for the given type.
|
<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 collection,
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 collection,
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 collection,
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 collection,
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)
Checks that an entity exists for the given key or entity
|
<T> Query<T> |
find(String collection,
Class<T> clazz)
Find all instances by type in a different collection than what is mapped on the class given.
|
<T,V> Query<T> |
find(String collection,
Class<T> clazz,
String property,
V value,
int offset,
int size)
Find all instances by type in a different collection than what is mapped on the class given skipping some documents and returning a
fixed number of the remaining.
|
<T> T |
get(Class<T> clazz,
DBRef ref)
Find the given entity (by collectionName/id);
|
<T,V> T |
get(String collection,
Class<T> clazz,
V id)
Finds an entity in the named collection whose id matches the value given.
|
long |
getCount(String collection)
Gets the count this collection
|
DBDecoderFactory |
getDecoderFact()
Returns the DBDecoderFactory used by this Datastore
|
<T> Iterable<Key<T>> |
insert(Iterable<T> entity)
Inserts an entity in to the mapped collection.
|
<T> Iterable<Key<T>> |
insert(Iterable<T> entities,
WriteConcern wc)
Inserts entities in to the mapped collection.
|
<T> Iterable<Key<T>> |
insert(String collection,
Iterable<T> entities)
Inserts an entity in to the named collection.
|
<T> Iterable<Key<T>> |
insert(String collection,
Iterable<T> entities,
WriteConcern wc)
Inserts an entity in to the named collection.
|
<T> Key<T> |
insert(String collection,
T entity)
Inserts an entity in to the named collection.
|
<T> Iterable<Key<T>> |
insert(T... entities)
Inserts entities in to the mapped collection.
|
<T> Key<T> |
insert(T entity)
Inserts an entity in to the mapped collection.
|
<T> Key<T> |
insert(T entity,
WriteConcern wc)
Inserts an entity in to the mapped collection.
|
<T> Query<T> |
queryByExample(String collection,
T example)
Returns a new query based on the example object
|
<T> Key<T> |
save(String collection,
T entity)
Saves an entity in to the named collection.
|
<T> Key<T> |
save(String collection,
T entity,
WriteConcern wc)
Saves an entity in to the named collection.
|
void |
setDecoderFact(DBDecoderFactory fact)
Sets the DBDecoderFactory to use in this 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<T> Query<T> createQuery(String collection, Class<T> clazz)
T - The type of the entitycollection - the collection to queryclazz - the class of objects to be returned<T> Query<T> createQuery(Class<T> clazz, DBObject q)
T - The type of the entityclazz - the class of objects to be returnedq - the query which will be passed to a QueryFactory<T> Query<T> createQuery(String collection, Class<T> clazz, DBObject q)
T - The type of the entitycollection - the collection to queryclazz - the class of objects to be returnedq - the query which will be passed to a QueryFactory<T,V> DBRef createRef(Class<T> clazz, V id)
T - The type of the entityV - The type of the ID valueclazz - The type of the entityid - The ID value of the entity<T> DBRef createRef(T entity)
T - The type of the entityentity - the entity to create a DBRef for<T> UpdateOperations<T> createUpdateOperations(Class<T> type, DBObject ops)
T - The type of the entitytype - The type of the entityops - The operations to perform<T,V> WriteResult delete(String kind, Class<T> clazz, V id)
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.T - the entity typeV - is the type of the ID, for example ObjectIdkind - the collection nameclazz - the Class of the entity to deleteid - the value of the ID<T,V> WriteResult delete(String kind, Class<T> clazz, V id, WriteConcern wc)
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.T - the entity typeV - is the type of the ID, for example ObjectIdkind - the collection nameclazz - the Class of the entity to deleteid - the value of the IDwc - the WriteConcern for this operation<T> void ensureIndex(String collection, Class<T> clazz, String fields)
T - the type to indexcollection - the collection to updateclazz - the class from which to get the index definitionsfields - the fields to index<T> void ensureIndex(String collection, Class<T> clazz, String name, String fields, boolean unique, boolean dropDupsOnCreate)
T - the type to indexcollection - the collection to updateclazz - the class from which to get the index definitionsname - the name of the index to createfields - the fields to indexunique - true if the index should enforce uniqueness on the fields indexeddropDupsOnCreate - if unique is true and this is true, any documents with duplicated fields being indexed will be dropped. If
this is false, index creation will fail.<T> void ensureIndexes(String collection, Class<T> clazz)
@Indexed, @Indexes) on the given collection
name.T - the type to indexcollection - the collection to updateclazz - the class from which to get the index definitions<T> void ensureIndexes(String collection, Class<T> clazz, boolean background)
@Indexed, @Indexes) on the given collection
name, possibly in the backgroundT - the type to indexcollection - the collection to updateclazz - the class from which to get the index definitionsbackground - if true, the index will be built in the background. If false, the method will block until the index is created.Key<?> exists(Object keyOrEntity, ReadPreference readPreference)
keyOrEntity - the value to check forreadPreference - Uses the supplied ReadPreference for the check. If readPreference is null the preference is taken from the
annotation or uses the default preference.Datastore.exists(Object)<T> Query<T> find(String collection, Class<T> clazz)
T - the type to querycollection - the collection to query againstclazz - the class to use for mapping the results<T,V> Query<T> find(String collection, Class<T> clazz, String property, V value, int offset, int size)
T - the type to queryV - the type to filter valuecollection - the collection to query againstclazz - the class to use for mapping the resultsproperty - the document property to query againstvalue - the value to check foroffset - the number of results to skipsize - the maximum number of results to return<T> T get(Class<T> clazz, DBRef ref)
T - the type to fetchclazz - the class to use for mappingref - the DBRef to use when querying<T,V> T get(String collection, Class<T> clazz, V id)
T - the type to fetchV - the type of the IDcollection - the collection to queryclazz - the class to use for mappingid - the ID to querylong getCount(String collection)
collection - the collection to countDBDecoderFactory getDecoderFact()
DBDecoderFactoryvoid setDecoderFact(DBDecoderFactory fact)
fact - the DBDecoderFactory to use<T> Key<T> insert(String collection, T entity)
T - the type of the entitycollection - the collection to updateentity - the entity to insert<T> Key<T> insert(T entity)
T - the type of the entityentity - the entity to insert<T> Iterable<Key<T>> insert(Iterable<T> entity)
T - the type of the entityentity - the entity to insert<T> Key<T> insert(T entity, WriteConcern wc)
T - the type of the entityentity - the entity to insertwc - the WriteConcern to use when insertingWriteConcern<T> Iterable<Key<T>> insert(T... entities)
T - the type of the entityentities - the entities to insert<T> Iterable<Key<T>> insert(Iterable<T> entities, WriteConcern wc)
T - the type of the entityentities - the entities to insertwc - the WriteConcern to use when inserting<T> Iterable<Key<T>> insert(String collection, Iterable<T> entities)
T - the type of the entitycollection - the collection to updateentities - the entities to insertWriteConcern<T> Iterable<Key<T>> insert(String collection, Iterable<T> entities, WriteConcern wc)
T - the type of the entitycollection - the collection to updateentities - the entities to insertwc - the WriteConcern to use when insertingWriteConcern<T> Query<T> queryByExample(String collection, T example)
T - the type of the entitycollection - the collection to queryexample - the example entity to use when building the query<T> Key<T> save(String collection, T entity)
T - the type of the entitycollection - the collection to updateentity - the entity to insert<T> Key<T> save(String collection, T entity, WriteConcern wc)
T - the type of the entitycollection - the collection to updateentity - the entity to insertwc - the WriteConcern to use when inserting