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 Detail

      • createAggregation

        AggregationPipeline createAggregation​(java.lang.Class source)
        Returns a new query bound to the kind (a specific DBCollection)
        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 specific DBCollection)
        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.
        use delete(Query) instead
        Deletes the given entity (by id)
        Type Parameters:
        T - the type to delete
        V - the type of the id
        Parameters:
        clazz - the type to delete
        id - 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.
        Deletes the given entity (by id)
        Type Parameters:
        T - the type to delete
        V - the type of the id
        Parameters:
        clazz - the type to delete
        id - the ID of the entity to delete
        options - 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.
        use delete(Query) instead
        Deletes the given entities (by id)
        Type Parameters:
        T - the type to delete
        V - the type of the id
        Parameters:
        clazz - the type to delete
        ids - 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.
        Deletes the given entities (by id)
        Type Parameters:
        T - the type to delete
        V - the type of the id
        Parameters:
        clazz - the type to delete
        ids - the IDs of the entity to delete
        options - 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 delete
        options - 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.
        Deletes 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 delete
        wc - 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 delete
        options - 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.
        Deletes the given entity (by @Id), with the WriteConcern
        Type Parameters:
        T - the type to delete
        Parameters:
        entity - the entity to delete
        wc - the WriteConcern to use when deleting
        Returns:
        results of the delete
      • ensureCaps

        void ensureCaps()
        ensure capped collections for Entity(s)
      • enableDocumentValidation

        void enableDocumentValidation()
        Process any Validation 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 definitions
        fields - 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 definitions
        name - the name of the index to create
        fields - the fields to index
        unique - true if the index should enforce uniqueness on the fields indexed
        dropDupsOnCreate - 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
        See Also:
        Indexes, Indexed, Text
      • ensureIndexes

        @Deprecated
        void ensureIndexes​(boolean background)
        Deprecated.
        use ensureIndexes() instead
        Ensures (creating if necessary) the indexes found during class mapping (using @Indexed, @Indexes) on the given collection name, possibly in the background
        Parameters:
        background - if true, the index will be built in the background. If false, background indexing is deferred to the annotation definition
        See Also:
        Indexes, Indexed, Text
      • ensureIndexes

        <T> void ensureIndexes​(java.lang.Class<T> clazz)
        Ensures (creating if necessary) the indexes found during class mapping
        Type Parameters:
        T - the type to index
        Parameters:
        clazz - the class from which to get the index definitions
        See Also:
        Indexes, Indexed, Text
      • ensureIndexes

        @Deprecated
        <T> void ensureIndexes​(java.lang.Class<T> clazz,
                               boolean background)
        Deprecated.
        Ensures (creating if necessary) the indexes found during class mapping
        Type Parameters:
        T - the type to index
        Parameters:
        clazz - the class from which to get the index definitions
        background - if true, the index will be built in the background. If false, background indexing is deferred to the annotation definition
        See Also:
        Indexes, Indexed, Text
      • exists

        @Deprecated
        Key<?> exists​(java.lang.Object keyOrEntity)
        Deprecated.
        use MongoIterable.first() instead
        Does 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.
        use Query instead

        Find all instances by collectionName, and filter property.

        This is the same as: find(clazzOrEntity).filter (property, value);

        Type Parameters:
        T - the type to query
        V - the type to filter value
        Parameters:
        clazz - the class to use for mapping the results
        property - the document property to query against
        value - 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.
        use Query instead
        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.
        Type Parameters:
        T - the type to query
        V - the type to filter value
        Parameters:
        clazz - the class to use for mapping the results
        property - the document property to query against
        value - the value to check for
        offset - the number of results to skip
        size - 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 delete
        options - 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 update
        operations - the updates to apply to the matched documents
        options - 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 update
        operations - 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)
        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 documents
        oldVersion - 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)
        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 documents
        oldVersion - indicated the old version of the Entity should be returned
        createIfMissing - 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.
        use Query instead.
        Find the given entities (by id); shorthand for find("_id in", ids)
        Type Parameters:
        T - the type to fetch
        V - the type of the ID
        Parameters:
        clazz - the class to use for mapping
        ids - 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.
        use Query instead
        Find the given entity (by id); shorthand for find("_id ", id)
        Type Parameters:
        T - the type to fetch
        V - the type of the ID
        Parameters:
        clazz - the class to use for mapping
        id - the ID to query
        Returns:
        the matched entity. may be null.
      • get

        @Deprecated
        <T> T get​(T entity)
        Deprecated.
        use Query instead
        Find 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 a Query instead
        Find the given entity (by collectionName/id);
        Type Parameters:
        T - the type to fetch
        Parameters:
        clazz - the class to use for mapping
        key - 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 a Query instead
        Find the given entities (by id), verifying they are of the correct type; shorthand for find("_id in", ids)
        Type Parameters:
        T - the type to fetch
        Parameters:
        clazz - the class to use for mapping
        keys - 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 a Query instead
        Find the given entities (by id); shorthand for find("_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.
        use Query.count() instead
        Gets 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.
        use Query.count() instead
        Gets 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.
        use Query.count() instead
        Gets the count of items returned by this query; same as query.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.
        Gets the count of items returned by this query; same as query.countAll()
        Type Parameters:
        T - the type to count
        Parameters:
        query - the query to filter the documents to count
        options - 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 a DBRef
        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 planned
        Get the underlying MongoClient that allows connection to the MongoDB instance being used.
        Returns:
        the MongoClient being used by this datastore.
      • setQueryFactory

        void setQueryFactory​(QueryFactory queryFactory)
        Replaces the current QueryFactory 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.0
        Runs 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.0
        Runs 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 yet
        type - MapreduceType
        q - The query (only the criteria, limit and sort will be used)
        map - The map function, in javascript, as a string
        reduce - The reduce function, in javascript, as a string
        finalize - The finalize function, in javascript, as a string; can be null
        scopeFields - 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.0
        Runs 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 - MapreduceType
        q - The query (only the criteria, limit and sort will be used)
        outputType - The type of resulting data; inline is not working yet
        baseCommand - 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 database
        wc - 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.
        Saves the entities (Objects) and updates the @Id field, with the WriteConcern
        Type Parameters:
        T - the type of the entity
        Parameters:
        entities - the entities to save
        wc - 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 save
        options - 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.
        Saves 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.
        Saves an entity (Object) and updates the @Id field, with the WriteConcern
        Type Parameters:
        T - the type of the entity
        Parameters:
        entity - the entity to save
        wc - 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 save
        options - 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.
        Updates an entity with the operations; this is an atomic operation
        Type Parameters:
        T - the type of the entity
        Parameters:
        entity - the entity to update
        operations - the update operations to perform
        Returns:
        the update results
        See Also:
        UpdateResults
      • update

        @Deprecated
        <T> UpdateResults update​(Key<T> key,
                                 UpdateOperations<T> operations)
        Deprecated.
        Updates 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 update
        operations - 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 update
        operations - 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 update
        operations - the update operations to perform
        options - 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.
        use update(Query, UpdateOperations, UpdateOptions) with upsert set to the value of createIfMissing
        Updates 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 update
        operations - the update operations to perform
        createIfMissing - 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.
        use update(Query, UpdateOperations, UpdateOptions) with upsert set to the value of createIfMissing
        Updates 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 update
        operations - the update operations to perform
        createIfMissing - if true, a document will be created if none can be found that match the query
        wc - the WriteConcern to use
        Returns:
        the results of the updates
      • updateFirst

        @Deprecated
        <T> UpdateResults updateFirst​(Query<T> query,
                                      UpdateOperations<T> operations)
        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 update
        operations - 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.
        use update(Query, UpdateOperations, UpdateOptions) with upsert set to the value of createIfMissing
        Updates 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 update
        operations - the update operations to perform
        createIfMissing - 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.
        use update(Query, UpdateOperations, UpdateOptions) with upsert set to the value of createIfMissing
        Updates 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 update
        operations - the update operations to perform
        createIfMissing - if true, a document will be created if none can be found that match the query
        wc - the WriteConcern to use
        Returns:
        the results of the updates
      • updateFirst

        @Deprecated
        <T> UpdateResults updateFirst​(Query<T> query,
                                      T entity,
                                      boolean createIfMissing)
        Deprecated.
        use update(Query, UpdateOperations, UpdateOptions) with upsert set to the value of createIfMissing
        updates 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 update
        entity - the entity whose state will be used as an update template for any matching documents
        createIfMissing - 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.