Package dev.morphia.dao
Class BasicDAO<T,K>
- java.lang.Object
-
- dev.morphia.dao.BasicDAO<T,K>
-
- Type Parameters:
T
- the type of the entityK
- 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
-
-
Field Summary
Fields Modifier and Type Field Description protected DatastoreImpl
ds
Deprecated.usegetDatastore()
protected java.lang.Class<T>
entityClazz
Deprecated.usegetEntityClass()
-
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 classesprotected
BasicDAO(Datastore ds)
Deprecated.BasicDAO(java.lang.Class<T> entityClass, com.mongodb.MongoClient mongoClient, Morphia morphia, java.lang.String dbName)
Deprecated.Create a new BasicDAOBasicDAO(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 typeUpdateOperations<T>
createUpdateOperations()
Deprecated.Starts a update-operations def for this DAO entities typecom.mongodb.WriteResult
delete(T entity)
Deprecated.Deletes an entitycom.mongodb.WriteResult
delete(T entity, com.mongodb.WriteConcern wc)
Deprecated.Deletes an entitycom.mongodb.WriteResult
deleteById(K id)
Deprecated.Delete the entity by id valuecom.mongodb.WriteResult
deleteByQuery(Query<T> query)
Deprecated.Delete the entity matching a queryvoid
ensureIndexes()
Deprecated.ensures indexed for this DAOboolean
exists(Query<T> query)
Deprecated.checks for entities which match the criteriaboolean
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 classQuery<T>
find(Query<T> query)
Deprecated.Finds entities matching a queryjava.util.List<K>
findIds()
Deprecated.Finds the entities Tsjava.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 Keyby 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 IDKey<T>
findOneId(Query<T> query)
Deprecated.Finds the first entity's IDKey<T>
findOneId(java.lang.String key, java.lang.Object value)
Deprecated.Finds the first entity's ID matching a queryT
get(K id)
Deprecated.Loads the entity by id valuecom.mongodb.DBCollection
getCollection()
Deprecated.Datastore
getDatastore()
Deprecated.DatastoreImpl
getDs()
Deprecated.usegetDatastore()
java.lang.Class<T>
getEntityClass()
Deprecated.The type of entities for this DAOjava.lang.Class<T>
getEntityClazz()
Deprecated.usegetEntityClass()
insteadprotected 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 Listto their id values Key<T>
save(T entity)
Deprecated.Saves the entity; either inserting or overriding the existing documentKey<T>
save(T entity, com.mongodb.WriteConcern wc)
Deprecated.Saves the entity; either inserting or overriding the existing documentUpdateResults
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.
-
-
-
Field Detail
-
entityClazz
@Deprecated protected java.lang.Class<T> entityClazz
Deprecated.usegetEntityClass()
-
ds
@Deprecated protected DatastoreImpl ds
Deprecated.usegetDatastore()
-
-
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 DAOmongoClient
- the representations of the connection to a MongoDB instancemorphia
- a Morphia instancedbName
- 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 DAOds
- 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 classesclass MyDao extends DAO<MyEntity, String>
- Parameters:
mongoClient
- the representations of the connection to a MongoDB instancemorphia
- a Morphia instancedbName
- the name of the database
-
BasicDAO
protected BasicDAO(Datastore ds)
Deprecated.
-
-
Method Detail
-
count
public long count()
Deprecated.
-
count
public long count(java.lang.String key, java.lang.Object value)
Deprecated.
-
createQuery
public Query<T> createQuery()
Deprecated.Description copied from interface:DAO
Starts a query for this DAO entities type- Specified by:
createQuery
in interfaceDAO<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 interfaceDAO<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
-
delete
public com.mongodb.WriteResult delete(T entity, com.mongodb.WriteConcern wc)
Deprecated.Description copied from interface:DAO
Deletes an entity
-
deleteById
public com.mongodb.WriteResult deleteById(K id)
Deprecated.Description copied from interface:DAO
Delete the entity by id value- Specified by:
deleteById
in interfaceDAO<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 interfaceDAO<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 interfaceDAO<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}
-
exists
public boolean exists(Query<T> query)
Deprecated.Description copied from interface:DAO
checks for entities which match the criteria
-
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 interfaceDAO<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
-
findIds
public java.util.List<K> findIds()
Deprecated.Description copied from interface:DAO
Finds the entities Ts
-
findIds
public java.util.List<K> findIds(java.lang.String key, java.lang.Object value)
Deprecated.Description copied from interface:DAO
Finds the entities Keyby the criteria {key:value}
-
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}
-
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.
-
findOne
public T findOne(Query<T> query)
Deprecated.Description copied from interface:DAO
Finds the first entity matching the query.
-
findOneId
public Key<T> findOneId()
Deprecated.Description copied from interface:DAO
Finds the first entity's ID
-
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
-
findOneId
public Key<T> findOneId(Query<T> query)
Deprecated.Description copied from interface:DAO
Finds the first entity's ID
-
get
public T get(K id)
Deprecated.Description copied from interface:DAO
Loads the entity by id value
-
getCollection
public com.mongodb.DBCollection getCollection()
Deprecated.- Specified by:
getCollection
in interfaceDAO<T,K>
- Returns:
- the collection mapped by the entity class
- See Also:
DAO.getEntityClass()
-
getDatastore
public Datastore getDatastore()
Deprecated.- Specified by:
getDatastore
in interfaceDAO<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 interfaceDAO<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
-
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
-
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.
-
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 interfaceDAO<T,K>
- Parameters:
query
- the query used to match the document to updateops
- the update operations to perform- Returns:
- the results of the update
-
getDs
@Deprecated public DatastoreImpl getDs()
Deprecated.usegetDatastore()
- Returns:
- the Datastore used by this DAO
-
getEntityClazz
@Deprecated public java.lang.Class<T> getEntityClazz()
Deprecated.usegetEntityClass()
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.
-
-