Package dev.morphia
Interface Datastore
-
- All Known Subinterfaces:
AdvancedDatastore
- All Known Implementing Classes:
DatastoreImpl
public interface Datastore
Datastore interface to get/delete/save objects- Author:
- Scott Hernandez
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description AggregationPipeline
createAggregation(java.lang.Class source)
Returns a new query bound to the kind (a specificDBCollection
)<T> Query<T>
createQuery(java.lang.Class<T> collection)
Returns a new query bound to the collection (a specificDBCollection
)<T> UpdateOperations<T>
createUpdateOperations(java.lang.Class<T> clazz)
The builder for all update operations<T> com.mongodb.WriteResult
delete(Query<T> query)
Deletes entities based on the query<T> com.mongodb.WriteResult
delete(Query<T> query, com.mongodb.WriteConcern wc)
Deprecated.usedelete(Query, DeleteOptions)
instead<T> com.mongodb.WriteResult
delete(Query<T> query, DeleteOptions options)
Deletes entities based on the query<T,V>
com.mongodb.WriteResultdelete(java.lang.Class<T> clazz, java.lang.Iterable<V> ids)
Deprecated.usedelete(Query)
instead<T,V>
com.mongodb.WriteResultdelete(java.lang.Class<T> clazz, java.lang.Iterable<V> ids, DeleteOptions options)
Deprecated.usedelete(Query, DeleteOptions)
instead<T,V>
com.mongodb.WriteResultdelete(java.lang.Class<T> clazz, V id)
Deprecated.usedelete(Query)
instead<T,V>
com.mongodb.WriteResultdelete(java.lang.Class<T> clazz, V id, DeleteOptions options)
Deprecated.usedelete(Query, DeleteOptions)
instead<T> com.mongodb.WriteResult
delete(T entity)
Deletes the given entity (by @Id)<T> com.mongodb.WriteResult
delete(T entity, com.mongodb.WriteConcern wc)
Deprecated.usedelete(Query, DeleteOptions)
instead<T> com.mongodb.WriteResult
delete(T entity, DeleteOptions options)
Deletes the given entity (by @Id), with the WriteConcernvoid
enableDocumentValidation()
Process anyValidation
annotations for document validation.void
ensureCaps()
ensure capped collections forEntity
(s)<T> void
ensureIndex(java.lang.Class<T> clazz, java.lang.String fields)
Deprecated.This method uses the legacy approach for defining indexes.<T> void
ensureIndex(java.lang.Class<T> clazz, java.lang.String name, java.lang.String fields, boolean unique, boolean dropDupsOnCreate)
Deprecated.This method uses the legacy approach for defining indexes.void
ensureIndexes()
Ensures (creating if necessary) the indexes found during class mappingvoid
ensureIndexes(boolean background)
Deprecated.useensureIndexes()
instead<T> void
ensureIndexes(java.lang.Class<T> clazz)
Ensures (creating if necessary) the indexes found during class mapping<T> void
ensureIndexes(java.lang.Class<T> clazz, boolean background)
Deprecated.useensureIndexes(Class)
insteadKey<?>
exists(java.lang.Object keyOrEntity)
Deprecated.useMongoIterable.first()
instead<T> Query<T>
find(java.lang.Class<T> clazz)
Find all instances by type<T,V>
Query<T>find(java.lang.Class<T> clazz, java.lang.String property, V value)
Deprecated.useQuery
instead<T,V>
Query<T>find(java.lang.Class<T> clazz, java.lang.String property, V value, int offset, int size)
Deprecated.useQuery
instead<T> T
findAndDelete(Query<T> query)
Deletes the given entities based on the query (first item only).<T> T
findAndDelete(Query<T> query, FindAndModifyOptions options)
Deletes the given entities based on the query (first item only).<T> T
findAndModify(Query<T> query, UpdateOperations<T> operations)
Find the first Entity from the Query, and modify it.<T> T
findAndModify(Query<T> query, UpdateOperations<T> operations, boolean oldVersion)
Deprecated.<T> T
findAndModify(Query<T> query, UpdateOperations<T> operations, boolean oldVersion, boolean createIfMissing)
Deprecated.<T> T
findAndModify(Query<T> query, UpdateOperations<T> operations, FindAndModifyOptions options)
Find the first Entity from the Query, and modify it.<T,V>
Query<T>get(java.lang.Class<T> clazz, java.lang.Iterable<V> ids)
Deprecated.useQuery
instead.<T,V>
Tget(java.lang.Class<T> clazz, V id)
Deprecated.useQuery
instead<T> T
get(T entity)
Deprecated.useQuery
instead<T> T
getByKey(java.lang.Class<T> clazz, Key<T> key)
Deprecated.use aQuery
instead<T> java.util.List<T>
getByKeys(java.lang.Class<T> clazz, java.lang.Iterable<Key<T>> keys)
Deprecated.use aQuery
instead<T> java.util.List<T>
getByKeys(java.lang.Iterable<Key<T>> keys)
Deprecated.use aQuery
insteadcom.mongodb.DBCollection
getCollection(java.lang.Class<?> clazz)
Deprecated.the return type for this method will change in 2.0<T> long
getCount(Query<T> query)
Deprecated.useQuery.count()
instead<T> long
getCount(Query<T> query, CountOptions options)
Deprecated.useQuery.count(CountOptions)
instead<T> long
getCount(java.lang.Class<T> clazz)
Deprecated.useQuery.count()
instead<T> long
getCount(T entity)
Deprecated.useQuery.count()
insteadcom.mongodb.client.MongoDatabase
getDatabase()
com.mongodb.DB
getDB()
Deprecated.use #getDatabase().com.mongodb.WriteConcern
getDefaultWriteConcern()
Deprecated.<T> Key<T>
getKey(T entity)
Deprecated.Mapper
getMapper()
com.mongodb.MongoClient
getMongo()
Deprecated.no replacement is plannedQueryFactory
getQueryFactory()
<T> MapreduceResults<T>
mapReduce(MapReduceOptions<T> options)
Deprecated.This feature will not be supported in 2.0<T> MapreduceResults<T>
mapReduce(MapreduceType type, Query q, java.lang.Class<T> outputType, com.mongodb.MapReduceCommand baseCommand)
Deprecated.This feature will not be supported in 2.0<T> MapreduceResults<T>
mapReduce(MapreduceType type, Query q, java.lang.String map, java.lang.String reduce, java.lang.String finalize, java.util.Map<java.lang.String,java.lang.Object> scopeFields, java.lang.Class<T> outputType)
Deprecated.This feature will not be supported in 2.0<T> Key<T>
merge(T entity)
Work as if you did an update with each field in the entity doing a $set; Only at the top level of the entity.<T> Key<T>
merge(T entity, com.mongodb.WriteConcern wc)
Work as if you did an update with each field in the entity doing a $set; Only at the top level of the entity.<T> Query<T>
queryByExample(T example)
Returns a new query based on the example object<T> java.lang.Iterable<Key<T>>
save(java.lang.Iterable<T> entities)
Saves the entities (Objects) and updates the @Id field The return type will change in 2.0<T> java.lang.Iterable<Key<T>>
save(java.lang.Iterable<T> entities, com.mongodb.WriteConcern wc)
Deprecated.usesave(Iterable, InsertOptions)
instead<T> java.lang.Iterable<Key<T>>
save(java.lang.Iterable<T> entities, InsertOptions options)
Saves the entities (Objects) and updates the @Id field, with the WriteConcern The return type will change in 2.0<T> Key<T>
save(T entity)
Saves an entity (Object) and updates the @Id field The return type will change in 2.0<T> java.lang.Iterable<Key<T>>
save(T... entities)
Deprecated.usesave(Iterable, InsertOptions)
instead<T> Key<T>
save(T entity, com.mongodb.WriteConcern wc)
Deprecated.usesave(Object, InsertOptions)
instead<T> Key<T>
save(T entity, InsertOptions options)
Saves an entity (Object) and updates the @Id field The return type will change in 2.0void
setDefaultWriteConcern(com.mongodb.WriteConcern wc)
Deprecated.MongoClient#setWriteConcern(WriteConcern)
void
setQueryFactory(QueryFactory queryFactory)
Replaces the currentQueryFactory
with the given value.<T> UpdateResults
update(Key<T> key, UpdateOperations<T> operations)
Deprecated.useupdate(Query, UpdateOperations)
instead<T> UpdateResults
update(Query<T> query, UpdateOperations<T> operations)
Updates all entities found with the operations; this is an atomic operation per entity<T> UpdateResults
update(Query<T> query, UpdateOperations<T> operations, boolean createIfMissing)
Deprecated.useupdate(Query, UpdateOperations, UpdateOptions)
with upsert set to the value of createIfMissing<T> UpdateResults
update(Query<T> query, UpdateOperations<T> operations, boolean createIfMissing, com.mongodb.WriteConcern wc)
Deprecated.useupdate(Query, UpdateOperations, UpdateOptions)
with upsert set to the value of createIfMissing<T> UpdateResults
update(Query<T> query, UpdateOperations<T> operations, UpdateOptions options)
Updates all entities found with the operations; this is an atomic operation per entity<T> UpdateResults
update(T entity, UpdateOperations<T> operations)
Deprecated.useupdate(Query, UpdateOperations)
instead<T> UpdateResults
updateFirst(Query<T> query, UpdateOperations<T> operations)
Deprecated.<T> UpdateResults
updateFirst(Query<T> query, UpdateOperations<T> operations, boolean createIfMissing)
Deprecated.useupdate(Query, UpdateOperations, UpdateOptions)
with upsert set to the value of createIfMissing<T> UpdateResults
updateFirst(Query<T> query, UpdateOperations<T> operations, boolean createIfMissing, com.mongodb.WriteConcern wc)
Deprecated.useupdate(Query, UpdateOperations, UpdateOptions)
with upsert set to the value of createIfMissing<T> UpdateResults
updateFirst(Query<T> query, T entity, boolean createIfMissing)
Deprecated.useupdate(Query, UpdateOperations, UpdateOptions)
with upsert set to the value of createIfMissing
-
-
-
Method Detail
-
createAggregation
AggregationPipeline createAggregation(java.lang.Class source)
Returns a new query bound to the kind (a specificDBCollection
)- Parameters:
source
- The class to create aggregation against- Returns:
- the aggregation pipeline
-
createQuery
<T> Query<T> createQuery(java.lang.Class<T> collection)
Returns a new query bound to the collection (a specificDBCollection
)- Type Parameters:
T
- the type of the query- Parameters:
collection
- The collection to query- Returns:
- the query
-
createUpdateOperations
<T> UpdateOperations<T> createUpdateOperations(java.lang.Class<T> clazz)
The builder for all update operations- Type Parameters:
T
- the type to update- Parameters:
clazz
- the type to update- Returns:
- the new UpdateOperations instance
-
delete
@Deprecated <T,V> com.mongodb.WriteResult delete(java.lang.Class<T> clazz, V id)
Deprecated.usedelete(Query)
insteadDeletes the given entity (by id)- Type Parameters:
T
- the type to deleteV
- the type of the id- Parameters:
clazz
- the type to deleteid
- the ID of the entity to delete- Returns:
- results of the delete
-
delete
@Deprecated <T,V> com.mongodb.WriteResult delete(java.lang.Class<T> clazz, V id, DeleteOptions options)
Deprecated.usedelete(Query, DeleteOptions)
insteadDeletes the given entity (by id)- Type Parameters:
T
- the type to deleteV
- the type of the id- Parameters:
clazz
- the type to deleteid
- the ID of the entity to deleteoptions
- the options to use when deleting- Returns:
- results of the delete
- Since:
- 1.3
-
delete
@Deprecated <T,V> com.mongodb.WriteResult delete(java.lang.Class<T> clazz, java.lang.Iterable<V> ids)
Deprecated.usedelete(Query)
insteadDeletes the given entities (by id)- Type Parameters:
T
- the type to deleteV
- the type of the id- Parameters:
clazz
- the type to deleteids
- the IDs of the entity to delete- Returns:
- results of the delete
-
delete
@Deprecated <T,V> com.mongodb.WriteResult delete(java.lang.Class<T> clazz, java.lang.Iterable<V> ids, DeleteOptions options)
Deprecated.usedelete(Query, DeleteOptions)
insteadDeletes the given entities (by id)- Type Parameters:
T
- the type to deleteV
- the type of the id- Parameters:
clazz
- the type to deleteids
- the IDs of the entity to deleteoptions
- the options to use when deleting- Returns:
- results of the delete
- Since:
- 1.3
-
delete
<T> com.mongodb.WriteResult delete(Query<T> query)
Deletes entities based on the query- Type Parameters:
T
- the type to delete- Parameters:
query
- the query to use when finding documents to delete- Returns:
- results of the delete
-
delete
<T> com.mongodb.WriteResult delete(Query<T> query, DeleteOptions options)
Deletes entities based on the query- Type Parameters:
T
- the type to delete- Parameters:
query
- the query to use when finding documents to deleteoptions
- the options to apply to the delete- Returns:
- results of the delete
- Since:
- 1.3
-
delete
@Deprecated <T> com.mongodb.WriteResult delete(Query<T> query, com.mongodb.WriteConcern wc)
Deprecated.usedelete(Query, DeleteOptions)
insteadDeletes entities based on the query, with the WriteConcern- Type Parameters:
T
- the type to delete- Parameters:
query
- the query to use when finding documents to deletewc
- the WriteConcern to use when deleting- Returns:
- results of the delete
-
delete
<T> com.mongodb.WriteResult delete(T entity)
Deletes the given entity (by @Id)- Type Parameters:
T
- the type to delete- Parameters:
entity
- the entity to delete- Returns:
- results of the delete
-
delete
<T> com.mongodb.WriteResult delete(T entity, DeleteOptions options)
Deletes the given entity (by @Id), with the WriteConcern- Type Parameters:
T
- the type to delete- Parameters:
entity
- the entity to deleteoptions
- the options to use when deleting- Returns:
- results of the delete
- Since:
- 1.3
-
delete
@Deprecated <T> com.mongodb.WriteResult delete(T entity, com.mongodb.WriteConcern wc)
Deprecated.usedelete(Query, DeleteOptions)
insteadDeletes the given entity (by @Id), with the WriteConcern- Type Parameters:
T
- the type to delete- Parameters:
entity
- the entity to deletewc
- the WriteConcern to use when deleting- Returns:
- results of the delete
-
ensureCaps
void ensureCaps()
ensure capped collections forEntity
(s)
-
enableDocumentValidation
void enableDocumentValidation()
Process anyValidation
annotations for document validation.- Since:
- 1.3
- MongoDB documentation
- core/document-validation/
-
ensureIndex
@Deprecated <T> void ensureIndex(java.lang.Class<T> clazz, java.lang.String fields)
Deprecated.This method uses the legacy approach for defining indexes. Switch to using annotations on entity classes or the methods in the Java driver itself.Ensures (creating if necessary) the index including the field(s) + directions on the given collection name; eg fields = "field1, -field2" ({field1:1, field2:-1})- Type Parameters:
T
- the type to index- Parameters:
clazz
- the class from which to get the index definitionsfields
- the fields to index- See Also:
MongoCollection.createIndex(org.bson.conversions.Bson, com.mongodb.client.model.IndexOptions)
-
ensureIndex
@Deprecated <T> void ensureIndex(java.lang.Class<T> clazz, java.lang.String name, java.lang.String fields, boolean unique, boolean dropDupsOnCreate)
Deprecated.This method uses the legacy approach for defining indexes. Switch to using annotations on entity classes or the methods in the Java driver itself.Ensures (creating if necessary) the index including the field(s) + directions on the given collection name; eg fields = "field1, -field2" ({field1:1, field2:-1})- Type Parameters:
T
- the type to index- Parameters:
clazz
- 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
- Support for this has been removed from the server. This value is ignored.- See Also:
MongoCollection.createIndex(org.bson.conversions.Bson, com.mongodb.client.model.IndexOptions)
-
ensureIndexes
void ensureIndexes()
Ensures (creating if necessary) the indexes found during class mapping
-
ensureIndexes
@Deprecated void ensureIndexes(boolean background)
Deprecated.useensureIndexes()
insteadEnsures (creating if necessary) the indexes found during class mapping (using@Indexed, @Indexes)
on the given collection name, possibly in the background
-
ensureIndexes
<T> void ensureIndexes(java.lang.Class<T> clazz)
Ensures (creating if necessary) the indexes found during class mapping
-
ensureIndexes
@Deprecated <T> void ensureIndexes(java.lang.Class<T> clazz, boolean background)
Deprecated.useensureIndexes(Class)
insteadEnsures (creating if necessary) the indexes found during class mapping
-
exists
@Deprecated Key<?> exists(java.lang.Object keyOrEntity)
Deprecated.useMongoIterable.first()
insteadDoes a query to check if the keyOrEntity exists in mongodb- Parameters:
keyOrEntity
- the value to check for- Returns:
- the key if the entity exists
-
find
<T> Query<T> find(java.lang.Class<T> clazz)
Find all instances by type- Type Parameters:
T
- the type to query- Parameters:
clazz
- the class to use for mapping the results- Returns:
- the query
-
find
@Deprecated <T,V> Query<T> find(java.lang.Class<T> clazz, java.lang.String property, V value)
Deprecated.useQuery
insteadFind all instances by collectionName, and filter property.
This is the same as:
find(clazzOrEntity).filter (property, value);
- Type Parameters:
T
- the type to queryV
- the type to filter value- Parameters:
clazz
- the class to use for mapping the resultsproperty
- the document property to query againstvalue
- the value to check for- Returns:
- the query
-
find
@Deprecated <T,V> Query<T> find(java.lang.Class<T> clazz, java.lang.String property, V value, int offset, int size)
Deprecated.useQuery
insteadFind 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.- Type Parameters:
T
- the type to queryV
- the type to filter value- Parameters:
clazz
- 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- Returns:
- the query
-
findAndDelete
<T> T findAndDelete(Query<T> query)
Deletes the given entities based on the query (first item only).- Type Parameters:
T
- the type to query- Parameters:
query
- the query to use when finding entities to delete- Returns:
- the deleted Entity
-
findAndDelete
<T> T findAndDelete(Query<T> query, FindAndModifyOptions options)
Deletes the given entities based on the query (first item only).- Type Parameters:
T
- the type to query- Parameters:
query
- the query to use when finding entities to deleteoptions
- the options to apply to the delete- Returns:
- the deleted Entity
- Since:
- 1.3
-
findAndModify
<T> T findAndModify(Query<T> query, UpdateOperations<T> operations, FindAndModifyOptions options)
Find the first Entity from the Query, and modify it.- Type Parameters:
T
- the type to query- Parameters:
query
- the query to use when finding entities to updateoperations
- the updates to apply to the matched documentsoptions
- the options to apply to the update- Returns:
- The modified Entity (the result of the update)
- Since:
- 1.3
-
findAndModify
<T> T findAndModify(Query<T> query, UpdateOperations<T> operations)
Find the first Entity from the Query, and modify it.- Type Parameters:
T
- the type to query- Parameters:
query
- the query to use when finding entities to updateoperations
- the updates to apply to the matched documents- Returns:
- The modified Entity (the result of the update)
-
findAndModify
@Deprecated <T> T findAndModify(Query<T> query, UpdateOperations<T> operations, boolean oldVersion)
Deprecated.Find the first Entity from the Query, and modify it.- Type Parameters:
T
- the type to query- Parameters:
query
- the query to find the Entity with; You are not allowed to offset/skip in the query.operations
- the updates to apply to the matched documentsoldVersion
- indicated the old version of the Entity should be returned- Returns:
- The Entity (the result of the update if oldVersion is false)
-
findAndModify
@Deprecated <T> T findAndModify(Query<T> query, UpdateOperations<T> operations, boolean oldVersion, boolean createIfMissing)
Deprecated.Find the first Entity from the Query, and modify it.- Type Parameters:
T
- the type of the entity- Parameters:
query
- the query to find the Entity with; You are not allowed to offset/skip in the query.operations
- the updates to apply to the matched documentsoldVersion
- indicated the old version of the Entity should be returnedcreateIfMissing
- if the query returns no results, then a new object will be created (sets upsert=true)- Returns:
- The Entity (the result of the update if oldVersion is false)
-
get
@Deprecated <T,V> Query<T> get(java.lang.Class<T> clazz, java.lang.Iterable<V> ids)
Deprecated.useQuery
instead.Find the given entities (by id); shorthand forfind("_id in", ids)
- Type Parameters:
T
- the type to fetchV
- the type of the ID- Parameters:
clazz
- the class to use for mappingids
- the IDs to query- Returns:
- the query to find the entities
Developer note. Inline this method to update to the new usage
-
get
@Deprecated <T,V> T get(java.lang.Class<T> clazz, V id)
Deprecated.useQuery
insteadFind the given entity (by id); shorthand forfind("_id ", id)
- Type Parameters:
T
- the type to fetchV
- the type of the ID- Parameters:
clazz
- the class to use for mappingid
- the ID to query- Returns:
- the matched entity. may be null.
-
get
@Deprecated <T> T get(T entity)
Deprecated.useQuery
insteadFind the given entity (by collectionName/id); think of this as refresh- Type Parameters:
T
- the type to fetch- Parameters:
entity
- The entity to search for- Returns:
- the matched entity. may be null.
Developer note. Inline this method to update to the new usage
-
getByKey
@Deprecated <T> T getByKey(java.lang.Class<T> clazz, Key<T> key)
Deprecated.use aQuery
insteadFind the given entity (by collectionName/id);- Type Parameters:
T
- the type to fetch- Parameters:
clazz
- the class to use for mappingkey
- the key search with- Returns:
- the matched entity. may be null.
-
getByKeys
@Deprecated <T> java.util.List<T> getByKeys(java.lang.Class<T> clazz, java.lang.Iterable<Key<T>> keys)
Deprecated.use aQuery
insteadFind the given entities (by id), verifying they are of the correct type; shorthand forfind("_id in", ids)
- Type Parameters:
T
- the type to fetch- Parameters:
clazz
- the class to use for mappingkeys
- the keys to search with- Returns:
- the matched entities. may be null.
-
getByKeys
@Deprecated <T> java.util.List<T> getByKeys(java.lang.Iterable<Key<T>> keys)
Deprecated.use aQuery
insteadFind the given entities (by id); shorthand forfind("_id in", ids)
- Type Parameters:
T
- the type to fetch- Parameters:
keys
- the keys to search with- Returns:
- the matched entities. may be null.
-
getCollection
@Deprecated com.mongodb.DBCollection getCollection(java.lang.Class<?> clazz)
Deprecated.the return type for this method will change in 2.0- Parameters:
clazz
- the class to use for mapping- Returns:
- the mapped collection for the collection
Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getCount
@Deprecated <T> long getCount(T entity)
Deprecated.useQuery.count()
insteadGets the count this kind (DBCollection
)- Type Parameters:
T
- the type to count- Parameters:
entity
- The entity whose type to count- Returns:
- the count
-
getCount
@Deprecated <T> long getCount(java.lang.Class<T> clazz)
Deprecated.useQuery.count()
insteadGets the count this kind (DBCollection
)- Type Parameters:
T
- the type to count- Parameters:
clazz
- The clazz type to count- Returns:
- the count
Developer note. Inline this method to update to the new usage
-
getCount
@Deprecated <T> long getCount(Query<T> query)
Deprecated.useQuery.count()
insteadGets the count of items returned by this query; same asquery.countAll()
- Type Parameters:
T
- the type to count- Parameters:
query
- the query to filter the documents to count- Returns:
- the count
Developer note. Inline this method to update to the new usage
-
getCount
@Deprecated <T> long getCount(Query<T> query, CountOptions options)
Deprecated.useQuery.count(CountOptions)
insteadGets the count of items returned by this query; same asquery.countAll()
- Type Parameters:
T
- the type to count- Parameters:
query
- the query to filter the documents to countoptions
- the options to apply to the count- Returns:
- the count
- Since:
- 1.3
-
getDB
@Deprecated com.mongodb.DB getDB()
Deprecated.use #getDatabase(). In general, should you need a DB reference, please use the MongoClient used to create this Datastore to retrieve it.- Returns:
- the DB this Datastore uses
- See Also:
MongoClient.getDB(String)
,MongoDatabase
-
getDatabase
com.mongodb.client.MongoDatabase getDatabase()
- Returns:
- the MongoDatabase used by this DataStore
- Since:
- 1.5
Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
getDefaultWriteConcern
@Deprecated com.mongodb.WriteConcern getDefaultWriteConcern()
Deprecated.- Returns:
- the default WriteConcern used by this Datastore
-
setDefaultWriteConcern
@Deprecated void setDefaultWriteConcern(com.mongodb.WriteConcern wc)
Deprecated.MongoClient#setWriteConcern(WriteConcern)
Sets the default WriteConcern for this Datastore- Parameters:
wc
- the default WriteConcern to be used by this Datastore
-
getKey
@Deprecated <T> Key<T> getKey(T entity)
Deprecated.Creates a (type-safe) reference to the entity; if stored this will become aDBRef
- Type Parameters:
T
- the type of the entity- Parameters:
entity
- the entity whose key is to be returned- Returns:
- the Key
-
getMongo
@Deprecated com.mongodb.MongoClient getMongo()
Deprecated.no replacement is plannedGet the underlying MongoClient that allows connection to the MongoDB instance being used.- Returns:
- the MongoClient being used by this datastore.
-
getQueryFactory
QueryFactory getQueryFactory()
- Returns:
- the current
QueryFactory
. - See Also:
QueryFactory
-
setQueryFactory
void setQueryFactory(QueryFactory queryFactory)
Replaces the currentQueryFactory
with the given value.- Parameters:
queryFactory
- the QueryFactory to use- See Also:
QueryFactory
-
mapReduce
@Deprecated <T> MapreduceResults<T> mapReduce(MapReduceOptions<T> options)
Deprecated.This feature will not be supported in 2.0Runs a map/reduce job at the server- Type Parameters:
T
- The type of resulting data- Parameters:
options
- the options to apply to the map/reduce job- Returns:
- the results
- Since:
- 1.3
-
mapReduce
@Deprecated <T> MapreduceResults<T> mapReduce(MapreduceType type, Query q, java.lang.String map, java.lang.String reduce, java.lang.String finalize, java.util.Map<java.lang.String,java.lang.Object> scopeFields, java.lang.Class<T> outputType)
Deprecated.This feature will not be supported in 2.0Runs a map/reduce job at the server; this should be used with a server version 1.7.4 or higher- Type Parameters:
T
- The type of resulting data- Parameters:
outputType
- The type of resulting data; inline is not working yettype
- MapreduceTypeq
- The query (only the criteria, limit and sort will be used)map
- The map function, in javascript, as a stringreduce
- The reduce function, in javascript, as a stringfinalize
- The finalize function, in javascript, as a string; can be nullscopeFields
- Each map entry will be a global variable in all the functions; can be null- Returns:
- counts and stuff
-
mapReduce
@Deprecated <T> MapreduceResults<T> mapReduce(MapreduceType type, Query q, java.lang.Class<T> outputType, com.mongodb.MapReduceCommand baseCommand)
Deprecated.This feature will not be supported in 2.0Runs a map/reduce job at the server; this should be used with a server version 1.7.4 or higher- Type Parameters:
T
- The type of resulting data- Parameters:
type
- MapreduceTypeq
- The query (only the criteria, limit and sort will be used)outputType
- The type of resulting data; inline is not working yetbaseCommand
- The base command to fill in and send to the server- Returns:
- counts and stuff
-
merge
<T> Key<T> merge(T entity)
Work as if you did an update with each field in the entity doing a $set; Only at the top level of the entity.- Type Parameters:
T
- the type of the entity- Parameters:
entity
- the entity to merge back in to the database- Returns:
- the key of the entity
-
merge
<T> Key<T> merge(T entity, com.mongodb.WriteConcern wc)
Work as if you did an update with each field in the entity doing a $set; Only at the top level of the entity.- Type Parameters:
T
- the type of the entity- Parameters:
entity
- the entity to merge back in to the databasewc
- the WriteConcern to use- Returns:
- the key of the entity
-
queryByExample
<T> Query<T> queryByExample(T example)
Returns a new query based on the example object- Type Parameters:
T
- the type of the entity- Parameters:
example
- the example entity to use when creating the query- Returns:
- the query
-
save
<T> java.lang.Iterable<Key<T>> save(java.lang.Iterable<T> entities)
Saves the entities (Objects) and updates the @Id field The return type will change in 2.0- Type Parameters:
T
- the type of the entity- Parameters:
entities
- the entities to save- Returns:
- the keys of the entities
-
save
@Deprecated <T> java.lang.Iterable<Key<T>> save(java.lang.Iterable<T> entities, com.mongodb.WriteConcern wc)
Deprecated.usesave(Iterable, InsertOptions)
insteadSaves the entities (Objects) and updates the @Id field, with the WriteConcern- Type Parameters:
T
- the type of the entity- Parameters:
entities
- the entities to savewc
- the WriteConcern to use- Returns:
- the keys of the entities
-
save
<T> java.lang.Iterable<Key<T>> save(java.lang.Iterable<T> entities, InsertOptions options)
Saves the entities (Objects) and updates the @Id field, with the WriteConcern The return type will change in 2.0- Type Parameters:
T
- the type of the entity- Parameters:
entities
- the entities to saveoptions
- the options to apply to the save operation- Returns:
- the keys of the entities
-
save
@Deprecated <T> java.lang.Iterable<Key<T>> save(T... entities)
Deprecated.usesave(Iterable, InsertOptions)
insteadSaves the entities (Objects) and updates the @Id field- Type Parameters:
T
- the type of the entity- Parameters:
entities
- the entities to save- Returns:
- the keys of the entities
-
save
<T> Key<T> save(T entity)
Saves an entity (Object) and updates the @Id field The return type will change in 2.0- Type Parameters:
T
- the type of the entity- Parameters:
entity
- the entity to save- Returns:
- the keys of the entity
-
save
@Deprecated <T> Key<T> save(T entity, com.mongodb.WriteConcern wc)
Deprecated.usesave(Object, InsertOptions)
insteadSaves an entity (Object) and updates the @Id field, with the WriteConcern- Type Parameters:
T
- the type of the entity- Parameters:
entity
- the entity to savewc
- the WriteConcern to use- Returns:
- the keys of the entity
-
save
<T> Key<T> save(T entity, InsertOptions options)
Saves an entity (Object) and updates the @Id field The return type will change in 2.0- Type Parameters:
T
- the type of the entity- Parameters:
entity
- the entity to saveoptions
- the options to apply to the save operation- Returns:
- the keys of the entity
-
update
@Deprecated <T> UpdateResults update(T entity, UpdateOperations<T> operations)
Deprecated.useupdate(Query, UpdateOperations)
insteadUpdates an entity with the operations; this is an atomic operation- Type Parameters:
T
- the type of the entity- Parameters:
entity
- the entity to updateoperations
- the update operations to perform- Returns:
- the update results
- See Also:
UpdateResults
-
update
@Deprecated <T> UpdateResults update(Key<T> key, UpdateOperations<T> operations)
Deprecated.useupdate(Query, UpdateOperations)
insteadUpdates an entity with the operations; this is an atomic operation- Type Parameters:
T
- the type of the entity- Parameters:
key
- the key of entity to updateoperations
- the update operations to perform- Returns:
- the update results
- See Also:
UpdateResults
-
update
<T> UpdateResults update(Query<T> query, UpdateOperations<T> operations)
Updates all entities found with the operations; this is an atomic operation per entity- Type Parameters:
T
- the type of the entity- Parameters:
query
- the query used to match the documents to updateoperations
- the update operations to perform- Returns:
- the results of the updates
-
update
<T> UpdateResults update(Query<T> query, UpdateOperations<T> operations, UpdateOptions options)
Updates all entities found with the operations; this is an atomic operation per entity- Type Parameters:
T
- the type of the entity- Parameters:
query
- the query used to match the documents to updateoperations
- the update operations to performoptions
- the options to apply to the update- Returns:
- the results of the updates
- Since:
- 1.3
-
update
@Deprecated <T> UpdateResults update(Query<T> query, UpdateOperations<T> operations, boolean createIfMissing)
Deprecated.useupdate(Query, UpdateOperations, UpdateOptions)
with upsert set to the value of createIfMissingUpdates all entities found with the operations, if nothing is found insert the update as an entity if "createIfMissing" is true; this is an atomic operation per entity- Type Parameters:
T
- the type of the entity- Parameters:
query
- the query used to match the documents to updateoperations
- the update operations to performcreateIfMissing
- if true, a document will be created if none can be found that match the query- Returns:
- the results of the updates
-
update
@Deprecated <T> UpdateResults update(Query<T> query, UpdateOperations<T> operations, boolean createIfMissing, com.mongodb.WriteConcern wc)
Deprecated.useupdate(Query, UpdateOperations, UpdateOptions)
with upsert set to the value of createIfMissingUpdates all entities found with the operations, if nothing is found insert the update as an entity if "createIfMissing" is true; this is an atomic operation per entity- Type Parameters:
T
- the type of the entity- Parameters:
query
- the query used to match the documents to updateoperations
- the update operations to performcreateIfMissing
- if true, a document will be created if none can be found that match the querywc
- the WriteConcern to use- Returns:
- the results of the updates
-
updateFirst
@Deprecated <T> UpdateResults updateFirst(Query<T> query, UpdateOperations<T> operations)
Deprecated.Updates the first entity found with the operations; this is an atomic operation- Type Parameters:
T
- the type of the entity- Parameters:
query
- the query used to match the document to updateoperations
- the update operations to perform- Returns:
- the results of the update
-
updateFirst
@Deprecated <T> UpdateResults updateFirst(Query<T> query, UpdateOperations<T> operations, boolean createIfMissing)
Deprecated.useupdate(Query, UpdateOperations, UpdateOptions)
with upsert set to the value of createIfMissingUpdates the first entity found with the operations, if nothing is found insert the update as an entity if "createIfMissing" is true.- Type Parameters:
T
- the type of the entity- Parameters:
query
- the query used to match the documents to updateoperations
- the update operations to performcreateIfMissing
- if true, a document will be created if none can be found that match the query- Returns:
- the results of the updates
-
updateFirst
@Deprecated <T> UpdateResults updateFirst(Query<T> query, UpdateOperations<T> operations, boolean createIfMissing, com.mongodb.WriteConcern wc)
Deprecated.useupdate(Query, UpdateOperations, UpdateOptions)
with upsert set to the value of createIfMissingUpdates the first entity found with the operations, if nothing is found insert the update as an entity if "createIfMissing" is true.- Type Parameters:
T
- the type of the entity- Parameters:
query
- the query used to match the documents to updateoperations
- the update operations to performcreateIfMissing
- if true, a document will be created if none can be found that match the querywc
- the WriteConcern to use- Returns:
- the results of the updates
-
updateFirst
@Deprecated <T> UpdateResults updateFirst(Query<T> query, T entity, boolean createIfMissing)
Deprecated.useupdate(Query, UpdateOperations, UpdateOptions)
with upsert set to the value of createIfMissingupdates the first entity found using the entity as a template, if nothing is found insert the update as an entity if "createIfMissing" is true.If the entity is a versioned entity, an UnsupportedOperationException is thrown.
- Type Parameters:
T
- the type of the entity- Parameters:
query
- the query used to match the documents to updateentity
- the entity whose state will be used as an update template for any matching documentscreateIfMissing
- if true, a document will be created if none can be found that match the query- Returns:
- the results of the updates
-
getMapper
Mapper getMapper()
- Returns:
- the Mapper used by this Datastore
- Since:
- 1.5
Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
-