Class BasicDAO<T,​K>

  • Type Parameters:
    T - the type of the entity
    K - the type of the key
    All Implemented Interfaces:
    DAO<T,​K>
    Direct Known Subclasses:
    DAO

    @Deprecated
    public class BasicDAO<T,​K>
    extends java.lang.Object
    implements DAO<T,​K>
    Deprecated.
    This interface poorly tracks Datastore's API. Use Datastore directly or wrap in an application specific DAO
    Author:
    Olafur Gauti Gudmundsson, Scott Hernandez
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected BasicDAO​(com.mongodb.MongoClient mongoClient, Morphia morphia, java.lang.String dbName)
      Deprecated.
      Only calls this from your derived class when you explicitly declare the generic types with concrete classes
      protected BasicDAO​(Datastore ds)
      Deprecated.
       
        BasicDAO​(java.lang.Class<T> entityClass, com.mongodb.MongoClient mongoClient, Morphia morphia, java.lang.String dbName)
      Deprecated.
      Create a new BasicDAO
        BasicDAO​(java.lang.Class<T> entityClass, Datastore ds)
      Deprecated.
      Create a new BasicDAO
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      long count()
      Deprecated.
       
      long count​(Query<T> query)
      Deprecated.
       
      long count​(java.lang.String key, java.lang.Object value)
      Deprecated.
       
      Query<T> createQuery()
      Deprecated.
      Starts a query for this DAO entities type
      UpdateOperations<T> createUpdateOperations()
      Deprecated.
      Starts a update-operations def for this DAO entities type
      com.mongodb.WriteResult delete​(T entity)
      Deprecated.
      Deletes an entity
      com.mongodb.WriteResult delete​(T entity, com.mongodb.WriteConcern wc)
      Deprecated.
      Deletes an entity
      com.mongodb.WriteResult deleteById​(K id)
      Deprecated.
      Delete the entity by id value
      com.mongodb.WriteResult deleteByQuery​(Query<T> query)
      Deprecated.
      Delete the entity matching a query
      void ensureIndexes()
      Deprecated.
      ensures indexed for this DAO
      boolean exists​(Query<T> query)
      Deprecated.
      checks for entities which match the criteria
      boolean exists​(java.lang.String key, java.lang.Object value)
      Deprecated.
      checks for entities which match criteria {key:value}
      Query<T> find()
      Deprecated.
      Finds all the documents in the collection mapped by the entity class
      Query<T> find​(Query<T> query)
      Deprecated.
      Finds entities matching a query
      java.util.List<K> findIds()
      Deprecated.
      Finds the entities Ts
      java.util.List<K> findIds​(Query<T> query)
      Deprecated.
      Finds the entities Ts by the criteria {key:value}
      java.util.List<K> findIds​(java.lang.String key, java.lang.Object value)
      Deprecated.
      Finds the entities Key by the criteria {key:value}
      T findOne​(Query<T> query)
      Deprecated.
      Finds the first entity matching the query.
      T findOne​(java.lang.String key, java.lang.Object value)
      Deprecated.
      Finds the first entity matching the query.
      Key<T> findOneId()
      Deprecated.
      Finds the first entity's ID
      Key<T> findOneId​(Query<T> query)
      Deprecated.
      Finds the first entity's ID
      Key<T> findOneId​(java.lang.String key, java.lang.Object value)
      Deprecated.
      Finds the first entity's ID matching a query
      T get​(K id)
      Deprecated.
      Loads the entity by id value
      com.mongodb.DBCollection getCollection()
      Deprecated.
       
      Datastore getDatastore()
      Deprecated.
       
      DatastoreImpl getDs()
      Deprecated.
      java.lang.Class<T> getEntityClass()
      Deprecated.
      The type of entities for this DAO
      java.lang.Class<T> getEntityClazz()
      Deprecated.
      use getEntityClass() instead
      protected void initDS​(com.mongodb.MongoClient mongoClient, Morphia mor, java.lang.String db)
      Deprecated.
       
      protected void initType​(java.lang.Class<T> type)
      Deprecated.
       
      protected java.util.List<?> keysToIds​(java.util.List<Key<T>> keys)
      Deprecated.
      Converts from a List to their id values
      Key<T> save​(T entity)
      Deprecated.
      Saves the entity; either inserting or overriding the existing document
      Key<T> save​(T entity, com.mongodb.WriteConcern wc)
      Deprecated.
      Saves the entity; either inserting or overriding the existing document
      UpdateResults update​(Query<T> query, UpdateOperations<T> ops)
      Deprecated.
      Updates all entities matched by the constraints with the modifiers supplied.
      UpdateResults updateFirst​(Query<T> query, UpdateOperations<T> ops)
      Deprecated.
      Updates the first entity matched by the constraints with the modifiers supplied.
      • Methods inherited from class java.lang.Object

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

      • BasicDAO

        public BasicDAO​(java.lang.Class<T> entityClass,
                        com.mongodb.MongoClient mongoClient,
                        Morphia morphia,
                        java.lang.String dbName)
        Deprecated.
        Create a new BasicDAO
        Parameters:
        entityClass - the class of the POJO you want to persist using this DAO
        mongoClient - the representations of the connection to a MongoDB instance
        morphia - a Morphia instance
        dbName - the name of the database
      • BasicDAO

        public BasicDAO​(java.lang.Class<T> entityClass,
                        Datastore ds)
        Deprecated.
        Create a new BasicDAO
        Parameters:
        entityClass - the class of the POJO you want to persist using this DAO
        ds - the Datastore which gives access to the MongoDB instance for this DAO
      • BasicDAO

        protected BasicDAO​(com.mongodb.MongoClient mongoClient,
                           Morphia morphia,
                           java.lang.String dbName)
        Deprecated.
        Only calls this from your derived class when you explicitly declare the generic types with concrete classes

        class MyDao extends DAO<MyEntity, String>

        Parameters:
        mongoClient - the representations of the connection to a MongoDB instance
        morphia - a Morphia instance
        dbName - the name of the database
      • BasicDAO

        protected BasicDAO​(Datastore ds)
        Deprecated.
    • Method Detail

      • count

        public long count()
        Deprecated.
        Specified by:
        count in interface DAO<T,​K>
        Returns:
        the total count
      • count

        public long count​(java.lang.String key,
                          java.lang.Object value)
        Deprecated.
        Specified by:
        count in interface DAO<T,​K>
        Parameters:
        key - The key to search with
        value - the value to look for
        Returns:
        the count which match criteria {key:value}
      • count

        public long count​(Query<T> query)
        Deprecated.
        Specified by:
        count in interface DAO<T,​K>
        Parameters:
        query - the query to use when counting
        Returns:
        the count which match the criteria
      • createQuery

        public Query<T> createQuery()
        Deprecated.
        Description copied from interface: DAO
        Starts a query for this DAO entities type
        Specified by:
        createQuery in interface DAO<T,​K>
        Returns:
        the query
      • createUpdateOperations

        public UpdateOperations<T> createUpdateOperations()
        Deprecated.
        Description copied from interface: DAO
        Starts a update-operations def for this DAO entities type
        Specified by:
        createUpdateOperations in interface DAO<T,​K>
        Returns:
        a new empty UpdateOperations instance
      • delete

        public com.mongodb.WriteResult delete​(T entity)
        Deprecated.
        Description copied from interface: DAO
        Deletes an entity
        Specified by:
        delete in interface DAO<T,​K>
        Parameters:
        entity - the entity to delete
        Returns:
        the results of the deletion
        See Also:
        WriteResult
      • delete

        public com.mongodb.WriteResult delete​(T entity,
                                              com.mongodb.WriteConcern wc)
        Deprecated.
        Description copied from interface: DAO
        Deletes an entity
        Specified by:
        delete in interface DAO<T,​K>
        Parameters:
        entity - the entity to delete
        wc - the WriteConcern to use when deleting
        Returns:
        the results of the deletion
        See Also:
        WriteConcern, WriteResult
      • deleteById

        public com.mongodb.WriteResult deleteById​(K id)
        Deprecated.
        Description copied from interface: DAO
        Delete the entity by id value
        Specified by:
        deleteById in interface DAO<T,​K>
        Parameters:
        id - the ID of the document to delete
        Returns:
        the results of the deletion
        See Also:
        WriteResult
      • deleteByQuery

        public com.mongodb.WriteResult deleteByQuery​(Query<T> query)
        Deprecated.
        Description copied from interface: DAO
        Delete the entity matching a query
        Specified by:
        deleteByQuery in interface DAO<T,​K>
        Parameters:
        query - the query to use when finding the documents to delete
        Returns:
        the results of the deletion
        See Also:
        WriteResult
      • ensureIndexes

        public void ensureIndexes()
        Deprecated.
        Description copied from interface: DAO
        ensures indexed for this DAO
        Specified by:
        ensureIndexes in interface DAO<T,​K>
      • exists

        public boolean exists​(java.lang.String key,
                              java.lang.Object value)
        Deprecated.
        Description copied from interface: DAO
        checks for entities which match criteria {key:value}
        Specified by:
        exists in interface DAO<T,​K>
        Parameters:
        key - the key to query
        value - the value to search for
        Returns:
        true if a document is found with a key matching the value
      • exists

        public boolean exists​(Query<T> query)
        Deprecated.
        Description copied from interface: DAO
        checks for entities which match the criteria
        Specified by:
        exists in interface DAO<T,​K>
        Parameters:
        query - the query to use when finding the documents
        Returns:
        true if a document is found matching the query
      • find

        public Query<T> find()
        Deprecated.
        Description copied from interface: DAO
        Finds all the documents in the collection mapped by the entity class
        Specified by:
        find in interface DAO<T,​K>
        Returns:
        the entities
        See Also:
        DAO.getEntityClass()
      • find

        public Query<T> find​(Query<T> query)
        Deprecated.
        Description copied from interface: DAO
        Finds entities matching a query
        Specified by:
        find in interface DAO<T,​K>
        Parameters:
        query - the query to use when finding the documents
        Returns:
        the entities which match the criteria
      • findIds

        public java.util.List<K> findIds()
        Deprecated.
        Description copied from interface: DAO
        Finds the entities Ts
        Specified by:
        findIds in interface DAO<T,​K>
        Returns:
        the list of IDs
      • findIds

        public java.util.List<K> findIds​(java.lang.String key,
                                         java.lang.Object value)
        Deprecated.
        Description copied from interface: DAO
        Finds the entities Key by the criteria {key:value}
        Specified by:
        findIds in interface DAO<T,​K>
        Parameters:
        key - the key to query
        value - the value to search for
        Returns:
        the list of IDs for documents matching the query
      • findIds

        public java.util.List<K> findIds​(Query<T> query)
        Deprecated.
        Description copied from interface: DAO
        Finds the entities Ts by the criteria {key:value}
        Specified by:
        findIds in interface DAO<T,​K>
        Parameters:
        query - the query to use when finding the documents
        Returns:
        the list of IDs for documents matching the query
      • findOne

        public T findOne​(java.lang.String key,
                         java.lang.Object value)
        Deprecated.
        Description copied from interface: DAO
        Finds the first entity matching the query.
        Specified by:
        findOne in interface DAO<T,​K>
        Parameters:
        key - the key to query
        value - the value to search for
        Returns:
        the entity which match criteria {key:value}
      • findOne

        public T findOne​(Query<T> query)
        Deprecated.
        Description copied from interface: DAO
        Finds the first entity matching the query.
        Specified by:
        findOne in interface DAO<T,​K>
        Parameters:
        query - the query to use when finding the documents
        Returns:
        the entity which match the criteria
      • findOneId

        public Key<T> findOneId()
        Deprecated.
        Description copied from interface: DAO
        Finds the first entity's ID
        Specified by:
        findOneId in interface DAO<T,​K>
        Returns:
        the Key of the first entity
      • findOneId

        public Key<T> findOneId​(java.lang.String key,
                                java.lang.Object value)
        Deprecated.
        Description copied from interface: DAO
        Finds the first entity's ID matching a query
        Specified by:
        findOneId in interface DAO<T,​K>
        Parameters:
        key - the key to query
        value - the value to search for
        Returns:
        the Key of the first entity
      • findOneId

        public Key<T> findOneId​(Query<T> query)
        Deprecated.
        Description copied from interface: DAO
        Finds the first entity's ID
        Specified by:
        findOneId in interface DAO<T,​K>
        Parameters:
        query - the query to use when finding the documents
        Returns:
        the Key of the first entity
      • get

        public T get​(K id)
        Deprecated.
        Description copied from interface: DAO
        Loads the entity by id value
        Specified by:
        get in interface DAO<T,​K>
        Parameters:
        id - the ID to search for
        Returns:
        the entity with the given ID or null if no document in the database has the given ID
      • getCollection

        public com.mongodb.DBCollection getCollection()
        Deprecated.
        Specified by:
        getCollection in interface DAO<T,​K>
        Returns:
        the collection mapped by the entity class
        See Also:
        DAO.getEntityClass()
      • getDatastore

        public Datastore getDatastore()
        Deprecated.
        Specified by:
        getDatastore in interface DAO<T,​K>
        Returns:
        the underlying datastore
      • getEntityClass

        public java.lang.Class<T> getEntityClass()
        Deprecated.
        Description copied from interface: DAO
        The type of entities for this DAO
        Specified by:
        getEntityClass in interface DAO<T,​K>
        Returns:
        the entity class
      • save

        public Key<T> save​(T entity)
        Deprecated.
        Description copied from interface: DAO
        Saves the entity; either inserting or overriding the existing document
        Specified by:
        save in interface DAO<T,​K>
        Parameters:
        entity - the entity to save
        Returns:
        the key of the entity
      • save

        public Key<T> save​(T entity,
                           com.mongodb.WriteConcern wc)
        Deprecated.
        Description copied from interface: DAO
        Saves the entity; either inserting or overriding the existing document
        Specified by:
        save in interface DAO<T,​K>
        Parameters:
        entity - the entity to save
        wc - the WriteConcern to use when saving
        Returns:
        the key of the entity
        See Also:
        WriteConcern
      • update

        public UpdateResults update​(Query<T> query,
                                    UpdateOperations<T> ops)
        Deprecated.
        Description copied from interface: DAO
        Updates all entities matched by the constraints with the modifiers supplied.
        Specified by:
        update in interface DAO<T,​K>
        Parameters:
        query - the query used to match the documents to update
        ops - the update operations to perform
        Returns:
        the results of the updates
      • updateFirst

        public UpdateResults updateFirst​(Query<T> query,
                                         UpdateOperations<T> ops)
        Deprecated.
        Description copied from interface: DAO
        Updates the first entity matched by the constraints with the modifiers supplied.
        Specified by:
        updateFirst in interface DAO<T,​K>
        Parameters:
        query - the query used to match the document to update
        ops - the update operations to perform
        Returns:
        the results of the update
      • getEntityClazz

        @Deprecated
        public java.lang.Class<T> getEntityClazz()
        Deprecated.
        use getEntityClass() instead
        Returns:
        the entity class
      • initDS

        protected void initDS​(com.mongodb.MongoClient mongoClient,
                              Morphia mor,
                              java.lang.String db)
        Deprecated.
      • initType

        protected void initType​(java.lang.Class<T> type)
        Deprecated.
      • keysToIds

        protected java.util.List<?> keysToIds​(java.util.List<Key<T>> keys)
        Deprecated.
        Converts from a List to their id values