| Modifier and Type | Field and Description |
|---|---|
protected DatastoreImpl |
ds
Deprecated.
please use the getter for this field
|
protected Class<T> |
entityClazz
Deprecated.
please use the getter for this field
|
| Modifier | Constructor and Description |
|---|---|
|
BasicDAO(Class<T> entityClass,
Datastore ds)
Create a new BasicDAO
|
|
BasicDAO(Class<T> entityClass,
MongoClient mongoClient,
Morphia morphia,
String dbName)
Create a new BasicDAO
|
protected |
BasicDAO(Datastore ds) |
protected |
BasicDAO(MongoClient mongoClient,
Morphia morphia,
String dbName)
Only calls this from your derived class when you explicitly declare the generic types with concrete classes
class MyDao extends DAO<MyEntity, String> |
| Modifier and Type | Method and Description |
|---|---|
long |
count() |
long |
count(Query<T> query) |
long |
count(String key,
Object value) |
Query<T> |
createQuery()
Starts a query for this DAO entities type
|
UpdateOperations<T> |
createUpdateOperations()
Starts a update-operations def for this DAO entities type
|
WriteResult |
delete(T entity)
Deletes an entity
|
WriteResult |
delete(T entity,
WriteConcern wc)
Deletes an entity
|
WriteResult |
deleteById(K id)
Delete the entity by id value
|
WriteResult |
deleteByQuery(Query<T> query)
Delete the entity matching a query
|
void |
ensureIndexes()
ensures indexed for this DAO
|
boolean |
exists(Query<T> query)
checks for entities which match the criteria
|
boolean |
exists(String key,
Object value)
checks for entities which match criteria {key:value}
|
QueryResults<T> |
find()
Finds all the documents in the collection mapped by the entity class
|
QueryResults<T> |
find(Query<T> query)
Finds entities matching a query
|
List<K> |
findIds()
Finds the entities Ts
|
List<K> |
findIds(Query<T> query)
Finds the entities Ts by the criteria {key:value}
|
List<K> |
findIds(String key,
Object value)
Finds the entities Key
|
T |
findOne(Query<T> query)
Finds the first entity matching the query.
|
T |
findOne(String key,
Object value)
Finds the first entity matching the query.
|
Key<T> |
findOneId()
Finds the first entity's ID
|
Key<T> |
findOneId(Query<T> query)
Finds the first entity's ID
|
Key<T> |
findOneId(String key,
Object value)
Finds the first entity's ID matching a query
|
T |
get(K id)
Loads the entity by id value
|
DBCollection |
getCollection() |
Datastore |
getDatastore() |
DatastoreImpl |
getDs() |
Class<T> |
getEntityClass()
The type of entities for this DAO
|
Class<T> |
getEntityClazz()
Deprecated.
use
getEntityClass() instead |
protected void |
initDS(MongoClient mongoClient,
Morphia mor,
String db) |
protected void |
initType(Class<T> type) |
protected List<?> |
keysToIds(List<Key<T>> keys)
Converts from a List
|
Key<T> |
save(T entity)
Saves the entity; either inserting or overriding the existing document
|
Key<T> |
save(T entity,
WriteConcern wc)
Saves the entity; either inserting or overriding the existing document
|
UpdateResults |
update(Query<T> query,
UpdateOperations<T> ops)
Updates all entities matched by the constraints with the modifiers supplied.
|
UpdateResults |
updateFirst(Query<T> query,
UpdateOperations<T> ops)
Updates the first entity matched by the constraints with the modifiers supplied.
|
protected DatastoreImpl ds
public BasicDAO(Class<T> entityClass, MongoClient mongoClient, Morphia morphia, String dbName)
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 databasepublic BasicDAO(Class<T> entityClass, Datastore ds)
entityClass - the class of the POJO you want to persist using this DAOds - the Datastore which gives access to the MongoDB instance for this DAOprotected BasicDAO(MongoClient mongoClient, Morphia morphia, String dbName)
class MyDao extends DAO<MyEntity, String>mongoClient - the representations of the connection to a MongoDB instancemorphia - a Morphia instancedbName - the name of the databaseprotected BasicDAO(Datastore ds)
public Query<T> createQuery()
DAOcreateQuery in interface DAO<T,K>public UpdateOperations<T> createUpdateOperations()
DAOcreateUpdateOperations in interface DAO<T,K>public WriteResult delete(T entity)
DAOdelete in interface DAO<T,K>entity - the entity to deleteWriteResultpublic WriteResult delete(T entity, WriteConcern wc)
DAOdelete in interface DAO<T,K>entity - the entity to deletewc - the WriteConcern to use when deletingWriteConcern,
WriteResultpublic WriteResult deleteById(K id)
DAOdeleteById in interface DAO<T,K>id - the ID of the document to deleteWriteResultpublic WriteResult deleteByQuery(Query<T> query)
DAOdeleteByQuery in interface DAO<T,K>query - the query to use when finding the documents to deleteWriteResultpublic void ensureIndexes()
DAOensureIndexes in interface DAO<T,K>public boolean exists(String key, Object value)
DAOpublic boolean exists(Query<T> query)
DAOpublic QueryResults<T> find()
DAOfind in interface DAO<T,K>DAO.getEntityClass()public QueryResults<T> find(Query<T> query)
DAOpublic List<K> findIds(String key, Object value)
DAOpublic List<K> findIds(Query<T> query)
DAOpublic T findOne(String key, Object value)
DAOpublic T findOne(Query<T> query)
DAOpublic Key<T> findOneId()
DAOpublic Key<T> findOneId(String key, Object value)
DAOpublic Key<T> findOneId(Query<T> query)
DAOpublic DBCollection getCollection()
getCollection in interface DAO<T,K>DAO.getEntityClass()public Datastore getDatastore()
getDatastore in interface DAO<T,K>public Class<T> getEntityClass()
DAOgetEntityClass in interface DAO<T,K>public Key<T> save(T entity)
DAOpublic Key<T> save(T entity, WriteConcern wc)
DAOsave in interface DAO<T,K>entity - the entity to savewc - the WriteConcern to use when savingWriteConcernpublic UpdateResults update(Query<T> query, UpdateOperations<T> ops)
DAOpublic UpdateResults updateFirst(Query<T> query, UpdateOperations<T> ops)
DAOupdateFirst in interface DAO<T,K>query - the query used to match the document to updateops - the update operations to performpublic DatastoreImpl getDs()
public Class<T> getEntityClazz()
getEntityClass() insteadprotected void initDS(MongoClient mongoClient, Morphia mor, String db)