| 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()
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
|
WriteResult |
delete(T entity)
Deletes the entity
|
WriteResult |
delete(T entity,
WriteConcern wc)
Deletes the entity
|
WriteResult |
deleteById(K id)
Delete the entity by id value
|
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
|
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() |
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> 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.
|
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)
protected void initDS(MongoClient mongoClient, Morphia mor, String db)
public DatastoreImpl getDs()
public 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, 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 WriteResult delete(T entity)
DAOpublic WriteResult delete(T entity, WriteConcern wc)
DAOpublic WriteResult deleteById(K id)
DAOdeleteById in interface DAO<T,K>public 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>