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()
DAO
createQuery
in interface DAO<T,K>
public UpdateOperations<T> createUpdateOperations()
DAO
createUpdateOperations
in interface DAO<T,K>
public Class<T> getEntityClass()
DAO
getEntityClass
in interface DAO<T,K>
public Key<T> save(T entity)
DAO
public Key<T> save(T entity, com.mongodb.WriteConcern wc)
DAO
public UpdateResults updateFirst(Query<T> q, UpdateOperations<T> ops)
DAO
updateFirst
in interface DAO<T,K>
public UpdateResults update(Query<T> q, UpdateOperations<T> ops)
DAO
public com.mongodb.WriteResult delete(T entity)
DAO
public com.mongodb.WriteResult delete(T entity, com.mongodb.WriteConcern wc)
DAO
public com.mongodb.WriteResult deleteById(K id)
DAO
deleteById
in interface DAO<T,K>
public com.mongodb.WriteResult deleteByQuery(Query<T> q)
DAO
deleteByQuery
in interface DAO<T,K>
public List<K> findIds(Query<T> q)
DAO
public List<K> findIds(String key, Object value)
DAO
public Key<T> findOneId()
DAO
public Key<T> findOneId(String key, Object value)
DAO
public Key<T> findOneId(Query<T> query)
DAO
public boolean exists(String key, Object value)
DAO
public boolean exists(Query<T> q)
DAO
public long count()
DAO
public long count(String key, Object value)
DAO
public long count(Query<T> q)
DAO
public T findOne(String key, Object value)
DAO
public T findOne(Query<T> q)
DAO
public QueryResults<T> find()
DAO
public QueryResults<T> find(Query<T> q)
DAO
public Datastore getDatastore()
DAO
getDatastore
in interface DAO<T,K>
public void ensureIndexes()
DAO
ensureIndexes
in interface DAO<T,K>
Copyright © 2016. All rights reserved.