| Constructor and Description |
|---|
BasicDAO(Class<T> entityClass,
Datastore ds)
Create a new BasicDAO
|
BasicDAO(Class<T> entityClass,
com.mongodb.MongoClient mongoClient,
Morphia morphia,
String dbName)
Create a new BasicDAO
|
| Modifier and Type | Method and Description |
|---|---|
long |
count()
returns the total count
|
long |
count(Query<T> q)
returns the count which match the criteria
|
long |
count(String key,
Object value)
returns the count which match criteria {key: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
|
com.mongodb.WriteResult |
delete(T entity)
Deletes the entity
|
com.mongodb.WriteResult |
delete(T entity,
com.mongodb.WriteConcern wc)
Deletes the entity
|
com.mongodb.WriteResult |
deleteById(K id)
Delete the entity by id value
|
com.mongodb.WriteResult |
deleteByQuery(Query<T> q)
Saves the entities given the query
|
void |
ensureIndexes()
ensures indexed for this DAO
|
boolean |
exists(Query<T> q)
checks for entities which match the criteria
|
boolean |
exists(String key,
Object value)
checks for entities which match criteria {key:value}
|
QueryResults<T> |
find()
returns the entities
|
QueryResults<T> |
find(Query<T> q)
returns the entities which match the criteria
|
List<K> |
findIds()
Finds the entities Ts
|
List<K> |
findIds(Query<T> q)
Finds the entities Ts by the criteria {key:value}
|
List<K> |
findIds(String key,
Object value)
Finds the entities Key
|
T |
findOne(Query<T> q)
returns the entity which match the criteria
|
T |
findOne(String key,
Object value)
returns the entity which match criteria {key:value}
|
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
|
T |
get(K id)
Loads the entity by id value
|
com.mongodb.DBCollection |
getCollection()
The underlying collection for this DAO
|
Datastore |
getDatastore()
returns the underlying datastore
|
DatastoreImpl |
getDs() |
Class<T> |
getEntityClass()
The type of entities for this DAO
|
Class<T> |
getEntityClazz() |
Key<T> |
save(T entity)
Saves the entity; either inserting or overriding the existing document
|
Key<T> |
save(T entity,
com.mongodb.WriteConcern wc)
Saves the entity; either inserting or overriding the existing document
|
UpdateResults |
update(Query<T> q,
UpdateOperations<T> ops)
Updates all entities matched by the constraints with the modifiers supplied.
|
UpdateResults |
updateFirst(Query<T> q,
UpdateOperations<T> ops)
Updates the first entity matched by the constraints with the modifiers supplied.
|
public BasicDAO(Class<T> entityClass, com.mongodb.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 DatastoreImpl getDs()
public com.mongodb.DBCollection getCollection()
getCollection in interface DAO<T,K>public Query<T> createQuery()
DAOcreateQuery in interface DAO<T,K>public UpdateOperations<T> createUpdateOperations()
DAOcreateUpdateOperations 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, com.mongodb.WriteConcern wc)
DAOpublic UpdateResults updateFirst(Query<T> q, UpdateOperations<T> ops)
DAOupdateFirst in interface DAO<T,K>public UpdateResults update(Query<T> q, UpdateOperations<T> ops)
DAOpublic com.mongodb.WriteResult delete(T entity)
DAOpublic com.mongodb.WriteResult delete(T entity, com.mongodb.WriteConcern wc)
DAOpublic com.mongodb.WriteResult deleteById(K id)
DAOdeleteById in interface DAO<T,K>public com.mongodb.WriteResult deleteByQuery(Query<T> q)
DAOdeleteByQuery in interface DAO<T,K>public List<K> findIds(Query<T> q)
DAOpublic List<K> findIds(String key, Object value)
DAOpublic Key<T> findOneId()
DAOpublic Key<T> findOneId(String key, Object value)
DAOpublic Key<T> findOneId(Query<T> query)
DAOpublic boolean exists(String key, Object value)
DAOpublic boolean exists(Query<T> q)
DAOpublic long count()
DAOpublic long count(String key, Object value)
DAOpublic long count(Query<T> q)
DAOpublic T findOne(String key, Object value)
DAOpublic T findOne(Query<T> q)
DAOpublic QueryResults<T> find()
DAOpublic QueryResults<T> find(Query<T> q)
DAOpublic Datastore getDatastore()
DAOgetDatastore in interface DAO<T,K>public void ensureIndexes()
DAOensureIndexes in interface DAO<T,K>Copyright © 2021. All rights reserved.