Package dev.morphia

Class DatastoreImpl

  • All Implemented Interfaces:
    AdvancedDatastore, Datastore

    @Deprecated
    public class DatastoreImpl
    extends java.lang.Object
    implements AdvancedDatastore
    Deprecated.
    This is an internal implementation of a published API. No public alternative planned.
    A generic (type-safe) wrapper around mongodb collections
    Developer note. This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
    • Constructor Summary

      Constructors 
      Constructor Description
      DatastoreImpl​(Morphia morphia, com.mongodb.MongoClient mongoClient, java.lang.String dbName)
      Deprecated.
      This is not meant to be directly instantiated by end user code.
      DatastoreImpl​(Morphia morphia, Mapper mapper, com.mongodb.MongoClient mongoClient, java.lang.String dbName)
      Deprecated.
      This is not meant to be directly instantiated by end user code.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      DatastoreImpl copy​(java.lang.String database)
      AggregationPipeline createAggregation​(java.lang.Class source)
      Deprecated.
      Returns a new query bound to the kind (a specific DBCollection)
      AggregationPipeline createAggregation​(java.lang.String collection, java.lang.Class<?> clazz)
      Deprecated.
      Returns an AggregationPipeline bound to the given collection and class.
      <T> Query<T> createQuery​(java.lang.Class<T> collection)
      Deprecated.
      Returns a new query bound to the collection (a specific DBCollection)
      <T> Query<T> createQuery​(java.lang.Class<T> clazz, com.mongodb.DBObject q)
      Deprecated.
       
      <T> Query<T> createQuery​(java.lang.String collection, java.lang.Class<T> type)
      Deprecated.
       
      <T,​V>
      com.mongodb.DBRef
      createRef​(java.lang.Class<T> clazz, V id)
      Deprecated.
      Creates a reference to the entity (using the current DB -can be null-, the collectionName, and id)
      <T> com.mongodb.DBRef createRef​(T entity)
      Deprecated.
      Creates a reference to the entity (using the current DB -can be null-, the collectionName, and id)
      <T> UpdateOperations<T> createUpdateOperations​(java.lang.Class<T> clazz)
      Deprecated.
      The builder for all update operations
      <T> UpdateOperations<T> createUpdateOperations​(java.lang.Class<T> type, com.mongodb.DBObject ops)
      Deprecated.
      Creates an UpdateOperations instance for the given type.
      <T> com.mongodb.WriteResult delete​(Query<T> query)
      Deprecated.
      Deletes entities based on the query
      <T> com.mongodb.WriteResult delete​(Query<T> query, DeleteOptions options)
      Deprecated.
      Deletes entities based on the query
      <T> com.mongodb.WriteResult delete​(T entity)
      Deprecated.
      Deletes the given entity (by @Id)
      <T> com.mongodb.WriteResult delete​(T entity, com.mongodb.WriteConcern wc)
      Deprecated.
       
      <T> com.mongodb.WriteResult delete​(T entity, DeleteOptions options)
      Deprecated.
      Deletes the given entity (by @Id), with the WriteConcern
      void enableDocumentValidation()
      Deprecated.
      Process any Validation annotations for document validation.
      void ensureCaps()
      Deprecated.
      ensure capped collections for Entity(s)
      void ensureIndexes()
      Deprecated.
      Ensures (creating if necessary) the indexes found during class mapping
      <T> void ensureIndexes​(java.lang.Class<T> clazz)
      Deprecated.
      Ensures (creating if necessary) the indexes found during class mapping
      Key<?> exists​(java.lang.Object entityOrKey)
      Deprecated.
      Does a query to check if the keyOrEntity exists in mongodb
      <T> Query<T> find​(java.lang.Class<T> clazz)
      Deprecated.
      Find all instances by type
      <T> Query<T> find​(java.lang.String collection)
      Deprecated.
      Find all instances by type in a different collection than what is mapped on the class given.
      <T,​V>
      Query<T>
      find​(java.lang.String collection, java.lang.Class<T> clazz, java.lang.String property, V value, int offset, int size, boolean validate)
      Deprecated.
      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 findAndDelete​(Query<T> query)
      Deprecated.
      Deletes the given entities based on the query (first item only).
      <T> T findAndDelete​(Query<T> query, FindAndModifyOptions options)
      Deprecated.
      Deletes the given entities based on the query (first item only).
      <T> T findAndModify​(Query<T> query, UpdateOperations<T> operations)
      Deprecated.
      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)
      Deprecated.
      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.
      Find the given entities (by id); shorthand for find("_id in", ids)
      <T,​V>
      T
      get​(java.lang.Class<T> clazz, V id)
      Deprecated.
       
      <T> T get​(T entity)
      Deprecated.
      Find the given entity (by collectionName/id); think of this as refresh
      <T> T getByKey​(java.lang.Class<T> clazz, Key<T> key)
      Deprecated.
      Find the given entity (by collectionName/id);
      <T> java.util.List<T> getByKeys​(java.lang.Class<T> clazz, java.lang.Iterable<Key<T>> keys)
      Deprecated.
      Find the given entities (by id), verifying they are of the correct type; shorthand for find("_id in", ids)
      <T> java.util.List<T> getByKeys​(java.lang.Iterable<Key<T>> keys)
      Deprecated.
      Find the given entities (by id); shorthand for find("_id in", ids)
      com.mongodb.DBCollection getCollection​(java.lang.Class clazz)
      Deprecated.
       
      com.mongodb.DBCollection getCollection​(java.lang.Object obj)
      Deprecated.
      this is an internal method.
      <T> long getCount​(Query<T> query)
      Deprecated.
       
      <T> long getCount​(java.lang.Class<T> clazz)
      Deprecated.
       
      com.mongodb.client.MongoDatabase getDatabase()
      Deprecated.
       
      com.mongodb.DB getDB()
      Deprecated.
       
      com.mongodb.DBDecoderFactory getDecoderFact()
      Deprecated.
      Returns the DBDecoderFactory used by this Datastore
      com.mongodb.WriteConcern getDefaultWriteConcern()
      Deprecated.
       
      protected java.lang.Object getId​(java.lang.Object entity)
      Deprecated.
      <T> Key<T> getKey​(T entity)
      Deprecated.
      Mapper getMapper()
      Deprecated.
       
      com.mongodb.MongoClient getMongo()
      Deprecated.
      Get the underlying MongoClient that allows connection to the MongoDB instance being used.
      QueryFactory getQueryFactory()
      Deprecated.
       
      protected <T> Key<T> insert​(com.mongodb.DBCollection dbColl, T entity, InsertOptions options)
      Deprecated.
       
      <T> java.lang.Iterable<Key<T>> insert​(java.lang.Iterable<T> entities)
      Deprecated.
      Inserts entities in to the database
      <T> java.lang.Iterable<Key<T>> insert​(java.lang.Iterable<T> entities, InsertOptions options)
      Deprecated.
      Inserts entities in to the mapped collection.
      <T> Key<T> insert​(java.lang.String collection, T entity, com.mongodb.WriteConcern wc)
      Deprecated.
      Inserts an entity in to the database
      <T> Key<T> insert​(T entity)
      Deprecated.
      Inserts an entity in to the mapped collection.
      <T> Key<T> insert​(T entity, InsertOptions options)
      Deprecated.
      Inserts an entity in to the mapped collection.
      <T> MapreduceResults<T> mapReduce​(MapReduceOptions<T> options)
      Deprecated.
      Runs a map/reduce job at the server
      <T> MapreduceResults<T> mapReduce​(MapreduceType type, Query query, java.lang.Class<T> outputType, com.mongodb.MapReduceCommand baseCommand)
      Deprecated.
      <T> MapreduceResults<T> mapReduce​(MapreduceType type, Query query, 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.
      <T> Key<T> merge​(T entity)
      Deprecated.
      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)
      Deprecated.
      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​(java.lang.String collection, T ex)
      Deprecated.
      Returns a new query based on the example object
      <T> Query<T> queryByExample​(T ex)
      Deprecated.
      Returns a new query based on the example object
      protected <T> Key<T> save​(com.mongodb.DBCollection dbColl, T entity, InsertOptions options)
      Deprecated.
       
      <T> java.lang.Iterable<Key<T>> save​(java.lang.Iterable<T> entities)
      Deprecated.
      Saves the entities (Objects) and updates the @Id field
      <T> java.lang.Iterable<Key<T>> save​(java.lang.Iterable<T> entities, InsertOptions options)
      Deprecated.
      Saves the entities (Objects) and updates the @Id field, with the WriteConcern
      <T> Key<T> save​(T entity)
      Deprecated.
      Saves an entity (Object) and updates the @Id field
      <T> Key<T> save​(T entity, InsertOptions options)
      Deprecated.
      Saves an entity (Object) and updates the @Id field
      void setDefaultWriteConcern​(com.mongodb.WriteConcern wc)
      Deprecated.
      Sets the default WriteConcern for this Datastore
      void setMapper​(Mapper mapper)
      Deprecated.
      Sets the Mapper this Datastore uses
      void setQueryFactory​(QueryFactory queryFactory)
      Deprecated.
      Replaces the current QueryFactory with the given value.
      <T> UpdateResults update​(Key<T> key, UpdateOperations<T> operations)
      Deprecated.
      Updates an entity with the operations; this is an atomic operation
      <T> UpdateResults update​(Query<T> query, UpdateOperations<T> operations)
      Deprecated.
      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.
      <T> UpdateResults update​(Query<T> query, UpdateOperations<T> operations, boolean createIfMissing, com.mongodb.WriteConcern wc)
      Deprecated.
      <T> UpdateResults update​(Query<T> query, UpdateOperations<T> operations, UpdateOptions options)
      Deprecated.
      Updates all entities found with the operations; this is an atomic operation per entity
      <T> UpdateResults update​(T entity, UpdateOperations<T> operations)
      Deprecated.
      Updates an entity with the operations; this is an atomic operation
      <T> UpdateResults updateFirst​(Query<T> query, UpdateOperations<T> operations)
      Deprecated.
      <T> UpdateResults updateFirst​(Query<T> query, UpdateOperations<T> operations, boolean createIfMissing)
      Deprecated.
      <T> UpdateResults updateFirst​(Query<T> query, UpdateOperations<T> operations, boolean createIfMissing, com.mongodb.WriteConcern wc)
      Deprecated.
      <T> UpdateResults updateFirst​(Query<T> query, T entity, boolean createIfMissing)
      Deprecated.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DatastoreImpl

        @Deprecated
        public DatastoreImpl​(Morphia morphia,
                             com.mongodb.MongoClient mongoClient,
                             java.lang.String dbName)
        Deprecated.
        This is not meant to be directly instantiated by end user code. Use Morphia.createDatastore(MongoClient, Mapper, String)
        Create a new DatastoreImpl
        Parameters:
        morphia - the Morphia instance
        mongoClient - the connection to the MongoDB instance
        dbName - the name of the database for this data store.
      • DatastoreImpl

        @Deprecated
        public DatastoreImpl​(Morphia morphia,
                             Mapper mapper,
                             com.mongodb.MongoClient mongoClient,
                             java.lang.String dbName)
        Deprecated.
        This is not meant to be directly instantiated by end user code. Use Morphia.createDatastore(MongoClient, Mapper, String)
        Create a new DatastoreImpl
        Parameters:
        morphia - the Morphia instance
        mapper - an initialised Mapper
        mongoClient - the connection to the MongoDB instance
        dbName - the name of the database for this data store.
    • Method Detail

      • copy

        @Deprecated
        public DatastoreImpl copy​(java.lang.String database)
        Creates a copy of this Datastore and all its configuration but with a new database
        Parameters:
        database - the new database to use for operations
        Returns:
        the new Datastore instance
      • createAggregation

        public AggregationPipeline createAggregation​(java.lang.Class source)
        Deprecated.
        Description copied from interface: Datastore
        Returns a new query bound to the kind (a specific DBCollection)
        Specified by:
        createAggregation in interface Datastore
        Parameters:
        source - the initial type/collection to aggregate against
        Returns:
        a new query bound to the kind (a specific DBCollection)
      • createAggregation

        public AggregationPipeline createAggregation​(java.lang.String collection,
                                                     java.lang.Class<?> clazz)
        Deprecated.
        Description copied from interface: AdvancedDatastore
        Returns an AggregationPipeline bound to the given collection and class.
        Specified by:
        createAggregation in interface AdvancedDatastore
        Parameters:
        collection - the collection to query
        clazz - The class to create aggregation against
        Returns:
        the aggregation pipeline
      • createQuery

        public <T> Query<T> createQuery​(java.lang.Class<T> collection)
        Deprecated.
        Description copied from interface: Datastore
        Returns a new query bound to the collection (a specific DBCollection)
        Specified by:
        createQuery in interface Datastore
        Type Parameters:
        T - the type of the query
        Parameters:
        collection - The collection to query
        Returns:
        the query
      • createUpdateOperations

        public <T> UpdateOperations<T> createUpdateOperations​(java.lang.Class<T> clazz)
        Deprecated.
        Description copied from interface: Datastore
        The builder for all update operations
        Specified by:
        createUpdateOperations in interface Datastore
        Type Parameters:
        T - the type to update
        Parameters:
        clazz - the type to update
        Returns:
        the new UpdateOperations instance
      • delete

        public <T> com.mongodb.WriteResult delete​(Query<T> query,
                                                  DeleteOptions options)
        Deprecated.
        Description copied from interface: Datastore
        Deletes entities based on the query
        Specified by:
        delete in interface Datastore
        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
      • delete

        public <T> com.mongodb.WriteResult delete​(Query<T> query)
        Deprecated.
        Description copied from interface: Datastore
        Deletes entities based on the query
        Specified by:
        delete in interface Datastore
        Type Parameters:
        T - the type to delete
        Parameters:
        query - the query to use when finding documents to delete
        Returns:
        results of the delete
      • delete

        public <T> com.mongodb.WriteResult delete​(T entity)
        Deprecated.
        Description copied from interface: Datastore
        Deletes the given entity (by @Id)
        Specified by:
        delete in interface Datastore
        Type Parameters:
        T - the type to delete
        Parameters:
        entity - the entity to delete
        Returns:
        results of the delete
      • delete

        public <T> com.mongodb.WriteResult delete​(T entity,
                                                  com.mongodb.WriteConcern wc)
        Deprecated.
      • delete

        public <T> com.mongodb.WriteResult delete​(T entity,
                                                  DeleteOptions options)
        Deprecated.
        Deletes the given entity (by @Id), with the WriteConcern
        Specified by:
        delete in interface Datastore
        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
      • ensureCaps

        public void ensureCaps()
        Deprecated.
        Description copied from interface: Datastore
        ensure capped collections for Entity(s)
        Specified by:
        ensureCaps in interface Datastore
      • exists

        public Key<?> exists​(java.lang.Object entityOrKey)
        Deprecated.
        Description copied from interface: Datastore
        Does a query to check if the keyOrEntity exists in mongodb
        Specified by:
        exists in interface Datastore
        Parameters:
        entityOrKey - the value to check for
        Returns:
        the key if the entity exists
      • find

        public <T> Query<T> find​(java.lang.Class<T> clazz)
        Deprecated.
        Description copied from interface: Datastore
        Find all instances by type
        Specified by:
        find in interface Datastore
        Type Parameters:
        T - the type to query
        Parameters:
        clazz - the class to use for mapping the results
        Returns:
        the query
      • findAndDelete

        public <T> T findAndDelete​(Query<T> query)
        Deprecated.
        Description copied from interface: Datastore
        Deletes the given entities based on the query (first item only).
        Specified by:
        findAndDelete in interface Datastore
        Type Parameters:
        T - the type to query
        Parameters:
        query - the query to use when finding entities to delete
        Returns:
        the deleted Entity
      • findAndDelete

        public <T> T findAndDelete​(Query<T> query,
                                   FindAndModifyOptions options)
        Deprecated.
        Description copied from interface: Datastore
        Deletes the given entities based on the query (first item only).
        Specified by:
        findAndDelete in interface Datastore
        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
      • findAndModify

        public <T> T findAndModify​(Query<T> query,
                                   UpdateOperations<T> operations,
                                   FindAndModifyOptions options)
        Deprecated.
        Description copied from interface: Datastore
        Find the first Entity from the Query, and modify it.
        Specified by:
        findAndModify in interface Datastore
        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)
      • findAndModify

        public <T> T findAndModify​(Query<T> query,
                                   UpdateOperations<T> operations)
        Deprecated.
        Description copied from interface: Datastore
        Find the first Entity from the Query, and modify it.
        Specified by:
        findAndModify in interface Datastore
        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
        public <T> T findAndModify​(Query<T> query,
                                   UpdateOperations<T> operations,
                                   boolean oldVersion)
        Deprecated.
        Description copied from interface: Datastore
        Find the first Entity from the Query, and modify it.
        Specified by:
        findAndModify in interface Datastore
        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
        public <T> T findAndModify​(Query<T> query,
                                   UpdateOperations<T> operations,
                                   boolean oldVersion,
                                   boolean createIfMissing)
        Deprecated.
        Description copied from interface: Datastore
        Find the first Entity from the Query, and modify it.
        Specified by:
        findAndModify in interface Datastore
        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

        public <T,​V> Query<T> get​(java.lang.Class<T> clazz,
                                        java.lang.Iterable<V> ids)
        Deprecated.
        Description copied from interface: Datastore
        Find the given entities (by id); shorthand for find("_id in", ids)
        Specified by:
        get in interface Datastore
        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
      • get

        public <T,​V> T get​(java.lang.Class<T> clazz,
                                 V id)
        Deprecated.
      • get

        public <T> T get​(T entity)
        Deprecated.
        Description copied from interface: Datastore
        Find the given entity (by collectionName/id); think of this as refresh
        Specified by:
        get in interface Datastore
        Type Parameters:
        T - the type to fetch
        Parameters:
        entity - The entity to search for
        Returns:
        the matched entity. may be null.
      • getByKey

        public <T> T getByKey​(java.lang.Class<T> clazz,
                              Key<T> key)
        Deprecated.
        Description copied from interface: Datastore
        Find the given entity (by collectionName/id);
        Specified by:
        getByKey in interface Datastore
        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

        public <T> java.util.List<T> getByKeys​(java.lang.Class<T> clazz,
                                               java.lang.Iterable<Key<T>> keys)
        Deprecated.
        Description copied from interface: Datastore
        Find the given entities (by id), verifying they are of the correct type; shorthand for find("_id in", ids)
        Specified by:
        getByKeys in interface Datastore
        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

        public <T> java.util.List<T> getByKeys​(java.lang.Iterable<Key<T>> keys)
        Deprecated.
        Description copied from interface: Datastore
        Find the given entities (by id); shorthand for find("_id in", ids)
        Specified by:
        getByKeys in interface Datastore
        Type Parameters:
        T - the type to fetch
        Parameters:
        keys - the keys to search with
        Returns:
        the matched entities. may be null.
      • getCollection

        @Deprecated
        public com.mongodb.DBCollection getCollection​(java.lang.Object obj)
        Deprecated.
        this is an internal method. no replacement is planned.
        Parameters:
        obj - the value to search with
        Returns:
        the DBCollection
      • getCollection

        public com.mongodb.DBCollection getCollection​(java.lang.Class clazz)
        Deprecated.
        Specified by:
        getCollection in interface Datastore
        Parameters:
        clazz - the class to use for mapping
        Returns:
        the mapped collection for the collection
      • getCount

        public <T> long getCount​(java.lang.Class<T> clazz)
        Deprecated.
      • getCount

        public <T> long getCount​(Query<T> query)
        Deprecated.
      • getDB

        public com.mongodb.DB getDB()
        Deprecated.
        Specified by:
        getDB in interface Datastore
        Returns:
        the DB this Datastore uses
        See Also:
        Mongo.getDB(String), MongoDatabase
      • getDatabase

        public com.mongodb.client.MongoDatabase getDatabase()
        Deprecated.
        Specified by:
        getDatabase in interface Datastore
        Returns:
        the MongoDatabase used by this DataStore
      • getDefaultWriteConcern

        public com.mongodb.WriteConcern getDefaultWriteConcern()
        Deprecated.
        Specified by:
        getDefaultWriteConcern in interface Datastore
        Returns:
        the default WriteConcern used by this Datastore
      • setDefaultWriteConcern

        public void setDefaultWriteConcern​(com.mongodb.WriteConcern wc)
        Deprecated.
        Description copied from interface: Datastore
        Sets the default WriteConcern for this Datastore
        Specified by:
        setDefaultWriteConcern in interface Datastore
        Parameters:
        wc - the default WriteConcern to be used by this Datastore
      • getKey

        @Deprecated
        public <T> Key<T> getKey​(T entity)
        Deprecated.
        Description copied from interface: Datastore
        Creates a (type-safe) reference to the entity; if stored this will become a DBRef
        Specified by:
        getKey in interface Datastore
        Type Parameters:
        T - the type of the entity
        Parameters:
        entity - the entity whose key is to be returned
        Returns:
        the Key
      • getMongo

        public com.mongodb.MongoClient getMongo()
        Deprecated.
        Description copied from interface: Datastore
        Get the underlying MongoClient that allows connection to the MongoDB instance being used.
        Specified by:
        getMongo in interface Datastore
        Returns:
        the MongoClient being used by this datastore.
      • mapReduce

        public <T> MapreduceResults<T> mapReduce​(MapReduceOptions<T> options)
        Deprecated.
        Description copied from interface: Datastore
        Runs a map/reduce job at the server
        Specified by:
        mapReduce in interface Datastore
        Type Parameters:
        T - The type of resulting data
        Parameters:
        options - the options to apply to the map/reduce job
        Returns:
        the results
      • mapReduce

        @Deprecated
        public <T> MapreduceResults<T> mapReduce​(MapreduceType type,
                                                 Query query,
                                                 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.
        Description copied from interface: Datastore
        Runs a map/reduce job at the server; this should be used with a server version 1.7.4 or higher
        Specified by:
        mapReduce in interface Datastore
        Type Parameters:
        T - The type of resulting data
        Parameters:
        type - MapreduceType
        query - 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
        outputType - The type of resulting data; inline is not working yet
        Returns:
        counts and stuff
      • mapReduce

        @Deprecated
        public <T> MapreduceResults<T> mapReduce​(MapreduceType type,
                                                 Query query,
                                                 java.lang.Class<T> outputType,
                                                 com.mongodb.MapReduceCommand baseCommand)
        Deprecated.
        Description copied from interface: Datastore
        Runs a map/reduce job at the server; this should be used with a server version 1.7.4 or higher
        Specified by:
        mapReduce in interface Datastore
        Type Parameters:
        T - The type of resulting data
        Parameters:
        type - MapreduceType
        query - 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

        public <T> Key<T> merge​(T entity)
        Deprecated.
        Description copied from interface: Datastore
        Work as if you did an update with each field in the entity doing a $set; Only at the top level of the entity.
        Specified by:
        merge in interface Datastore
        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

        public <T> Key<T> merge​(T entity,
                                com.mongodb.WriteConcern wc)
        Deprecated.
        Description copied from interface: Datastore
        Work as if you did an update with each field in the entity doing a $set; Only at the top level of the entity.
        Specified by:
        merge in interface Datastore
        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

        public <T> Query<T> queryByExample​(T ex)
        Deprecated.
        Description copied from interface: Datastore
        Returns a new query based on the example object
        Specified by:
        queryByExample in interface Datastore
        Type Parameters:
        T - the type of the entity
        Parameters:
        ex - the example entity to use when creating the query
        Returns:
        the query
      • save

        public <T> java.lang.Iterable<Key<T>> save​(java.lang.Iterable<T> entities)
        Deprecated.
        Description copied from interface: Datastore
        Saves the entities (Objects) and updates the @Id field
        Specified by:
        save in interface Datastore
        Type Parameters:
        T - the type of the entity
        Parameters:
        entities - the entities to save
        Returns:
        the keys of the entities
      • save

        public <T> java.lang.Iterable<Key<T>> save​(java.lang.Iterable<T> entities,
                                                   InsertOptions options)
        Deprecated.
        Description copied from interface: Datastore
        Saves the entities (Objects) and updates the @Id field, with the WriteConcern
        Specified by:
        save in interface Datastore
        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

        public <T> Key<T> save​(T entity)
        Deprecated.
        Description copied from interface: Datastore
        Saves an entity (Object) and updates the @Id field
        Specified by:
        save in interface Datastore
        Type Parameters:
        T - the type of the entity
        Parameters:
        entity - the entity to save
        Returns:
        the keys of the entity
      • save

        public <T> Key<T> save​(T entity,
                               InsertOptions options)
        Deprecated.
        Description copied from interface: Datastore
        Saves an entity (Object) and updates the @Id field
        Specified by:
        save in interface Datastore
        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

        public <T> UpdateResults update​(T entity,
                                        UpdateOperations<T> operations)
        Deprecated.
        Description copied from interface: Datastore
        Updates an entity with the operations; this is an atomic operation
        Specified by:
        update in interface Datastore
        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

        public <T> UpdateResults update​(Key<T> key,
                                        UpdateOperations<T> operations)
        Deprecated.
        Description copied from interface: Datastore
        Updates an entity with the operations; this is an atomic operation
        Specified by:
        update in interface Datastore
        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

        public <T> UpdateResults update​(Query<T> query,
                                        UpdateOperations<T> operations)
        Deprecated.
        Description copied from interface: Datastore
        Updates all entities found with the operations; this is an atomic operation per entity
        Specified by:
        update in interface Datastore
        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

        @Deprecated
        public <T> UpdateResults update​(Query<T> query,
                                        UpdateOperations<T> operations,
                                        boolean createIfMissing)
        Deprecated.
        Description copied from interface: Datastore
        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
        Specified by:
        update in interface Datastore
        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
        public <T> UpdateResults update​(Query<T> query,
                                        UpdateOperations<T> operations,
                                        boolean createIfMissing,
                                        com.mongodb.WriteConcern wc)
        Deprecated.
        Description copied from interface: Datastore
        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
        Specified by:
        update in interface Datastore
        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
        public <T> UpdateResults updateFirst​(Query<T> query,
                                             UpdateOperations<T> operations)
        Deprecated.
        Description copied from interface: Datastore
        Updates the first entity found with the operations; this is an atomic operation
        Specified by:
        updateFirst in interface Datastore
        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
        public <T> UpdateResults updateFirst​(Query<T> query,
                                             UpdateOperations<T> operations,
                                             boolean createIfMissing)
        Deprecated.
        Description copied from interface: Datastore
        Updates the first entity found with the operations, if nothing is found insert the update as an entity if "createIfMissing" is true.
        Specified by:
        updateFirst in interface Datastore
        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
        public <T> UpdateResults updateFirst​(Query<T> query,
                                             UpdateOperations<T> operations,
                                             boolean createIfMissing,
                                             com.mongodb.WriteConcern wc)
        Deprecated.
        Description copied from interface: Datastore
        Updates the first entity found with the operations, if nothing is found insert the update as an entity if "createIfMissing" is true.
        Specified by:
        updateFirst in interface Datastore
        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
        public <T> UpdateResults updateFirst​(Query<T> query,
                                             T entity,
                                             boolean createIfMissing)
        Deprecated.
        Description copied from interface: Datastore
        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.

        Specified by:
        updateFirst in interface Datastore
        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
      • createQuery

        public <T> Query<T> createQuery​(java.lang.String collection,
                                        java.lang.Class<T> type)
        Deprecated.
        Specified by:
        createQuery in interface AdvancedDatastore
        Type Parameters:
        T - The type of the entity
        Parameters:
        collection - the collection to query
        type - the class of objects to be returned
        Returns:
        Query for the specified class clazz
      • createQuery

        public <T> Query<T> createQuery​(java.lang.Class<T> clazz,
                                        com.mongodb.DBObject q)
        Deprecated.
        Specified by:
        createQuery in interface AdvancedDatastore
        Type Parameters:
        T - The type of the entity
        Parameters:
        clazz - the class of objects to be returned
        q - the query which will be passed to a QueryFactory
        Returns:
        Query for the specified class clazz
      • createRef

        public <T,​V> com.mongodb.DBRef createRef​(java.lang.Class<T> clazz,
                                                       V id)
        Deprecated.
        Description copied from interface: AdvancedDatastore
        Creates a reference to the entity (using the current DB -can be null-, the collectionName, and id)
        Specified by:
        createRef in interface AdvancedDatastore
        Type Parameters:
        T - The type of the entity
        V - The type of the ID value
        Parameters:
        clazz - The type of the entity
        id - The ID value of the entity
        Returns:
        the DBRef for the entity
      • createRef

        public <T> com.mongodb.DBRef createRef​(T entity)
        Deprecated.
        Description copied from interface: AdvancedDatastore
        Creates a reference to the entity (using the current DB -can be null-, the collectionName, and id)
        Specified by:
        createRef in interface AdvancedDatastore
        Type Parameters:
        T - The type of the entity
        Parameters:
        entity - the entity to create a DBRef for
        Returns:
        the DBRef for the entity
      • createUpdateOperations

        public <T> UpdateOperations<T> createUpdateOperations​(java.lang.Class<T> type,
                                                              com.mongodb.DBObject ops)
        Deprecated.
        Description copied from interface: AdvancedDatastore
        Creates an UpdateOperations instance for the given type.
        Specified by:
        createUpdateOperations in interface AdvancedDatastore
        Type Parameters:
        T - The type of the entity
        Parameters:
        type - The type of the entity
        ops - The operations to perform
        Returns:
        the UpdateOperations instance
      • ensureIndexes

        public void ensureIndexes()
        Deprecated.
        Description copied from interface: Datastore
        Ensures (creating if necessary) the indexes found during class mapping
        Specified by:
        ensureIndexes in interface Datastore
        See Also:
        Indexes, Indexed, Text
      • ensureIndexes

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

        public <T> Query<T> find​(java.lang.String collection)
        Deprecated.
        Description copied from interface: AdvancedDatastore
        Find all instances by type in a different collection than what is mapped on the class given.
        Specified by:
        find in interface AdvancedDatastore
        Type Parameters:
        T - the type to query
        Parameters:
        collection - the collection to query against
        Returns:
        the query
      • getDecoderFact

        public com.mongodb.DBDecoderFactory getDecoderFact()
        Deprecated.
        Description copied from interface: AdvancedDatastore
        Returns the DBDecoderFactory used by this Datastore
        Specified by:
        getDecoderFact in interface AdvancedDatastore
        Returns:
        the decoder factory
        See Also:
        DBDecoderFactory
      • insert

        public <T> Key<T> insert​(T entity)
        Deprecated.
        Description copied from interface: AdvancedDatastore
        Inserts an entity in to the mapped collection.
        Specified by:
        insert in interface AdvancedDatastore
        Type Parameters:
        T - the type of the entity
        Parameters:
        entity - the entity to insert
        Returns:
        the new key of the inserted entity
      • insert

        public <T> Key<T> insert​(T entity,
                                 InsertOptions options)
        Deprecated.
        Description copied from interface: AdvancedDatastore
        Inserts an entity in to the mapped collection.
        Specified by:
        insert in interface AdvancedDatastore
        Type Parameters:
        T - the type of the entity
        Parameters:
        entity - the entity to insert
        options - the options to apply to the insert operation
        Returns:
        the new key of the inserted entity
      • insert

        public <T> java.lang.Iterable<Key<T>> insert​(java.lang.Iterable<T> entities,
                                                     InsertOptions options)
        Deprecated.
        Description copied from interface: AdvancedDatastore
        Inserts entities in to the mapped collection.
        Specified by:
        insert in interface AdvancedDatastore
        Type Parameters:
        T - the type of the entity
        Parameters:
        entities - the entities to insert
        options - the options to apply to the insert operation
        Returns:
        the new keys of the inserted entities
      • queryByExample

        public <T> Query<T> queryByExample​(java.lang.String collection,
                                           T ex)
        Deprecated.
        Description copied from interface: AdvancedDatastore
        Returns a new query based on the example object
        Specified by:
        queryByExample in interface AdvancedDatastore
        Type Parameters:
        T - the type of the entity
        Parameters:
        collection - the collection to query
        ex - the example entity to use when building the query
        Returns:
        the query
      • find

        public <T,​V> Query<T> find​(java.lang.String collection,
                                         java.lang.Class<T> clazz,
                                         java.lang.String property,
                                         V value,
                                         int offset,
                                         int size,
                                         boolean validate)
        Deprecated.
        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:
        collection - The collection use when querying
        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
        validate - if true, validate the query
        Returns:
        the query
      • getMapper

        public Mapper getMapper()
        Deprecated.
        Specified by:
        getMapper in interface Datastore
        Returns:
        the Mapper used by this Datastore
      • setMapper

        public void setMapper​(Mapper mapper)
        Deprecated.
        Sets the Mapper this Datastore uses
        Parameters:
        mapper - the new Mapper
      • insert

        public <T> java.lang.Iterable<Key<T>> insert​(java.lang.Iterable<T> entities)
        Deprecated.
        Inserts entities in to the database
        Specified by:
        insert in interface AdvancedDatastore
        Type Parameters:
        T - the type of the entities
        Parameters:
        entities - the entities to insert
        Returns:
        the keys of entities
      • insert

        public <T> Key<T> insert​(java.lang.String collection,
                                 T entity,
                                 com.mongodb.WriteConcern wc)
        Deprecated.
        Inserts an entity in to the database
        Type Parameters:
        T - the type of the entities
        Parameters:
        collection - the collection to query against
        entity - the entity to insert
        wc - the WriteConcern to use when deleting
        Returns:
        the key of entity
      • getId

        @Deprecated
        protected java.lang.Object getId​(java.lang.Object entity)
        Deprecated.
      • insert

        protected <T> Key<T> insert​(com.mongodb.DBCollection dbColl,
                                    T entity,
                                    InsertOptions options)
        Deprecated.
      • save

        protected <T> Key<T> save​(com.mongodb.DBCollection dbColl,
                                  T entity,
                                  InsertOptions options)
        Deprecated.
      • update

        public <T> UpdateResults update​(Query<T> query,
                                        UpdateOperations<T> operations,
                                        UpdateOptions options)
        Deprecated.
        Description copied from interface: Datastore
        Updates all entities found with the operations; this is an atomic operation per entity
        Specified by:
        update in interface Datastore
        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