| Constructor and Description |
|---|
MongoDaoImpl()
Creates the
MongoDaoImpl. |
MongoDaoImpl(com.mongodb.DB db,
ObjectMapper objectMapper)
Creates the
MongoDaoImpl. |
| Modifier and Type | Method and Description |
|---|---|
long |
countObjects(java.lang.String collection,
com.mongodb.DBObject query)
Returns the count of objects matching the given query
in the given collection.
|
<T> T |
createObject(java.lang.String collection,
T object)
Creates the object in the given collection.
|
<T> T |
createObject(java.lang.String collection,
T object,
com.mongodb.WriteConcern concern)
Creates the object in the given collection.
|
<T> T[] |
createObjects(java.lang.String collection,
T[] objects)
Creates the given objects in the given collection.
|
<T> T[] |
createObjects(java.lang.String collection,
T[] objects,
com.mongodb.WriteConcern concern)
Creates the given objects in the given collection.
|
DaoQuery |
createQuery()
Creates a
DaoQuery and returns it. |
Statement |
createStatement(java.lang.String mql)
Creates a
Statement from the given mql code
and returns it. |
void |
deleteObject(java.lang.String collection,
java.lang.Object id)
Deletes the object with the given id from the
given collection.
|
void |
deleteObject(java.lang.String collection,
java.lang.Object id,
com.mongodb.WriteConcern concern)
Deletes the object with the given id from the
given collection.
|
void |
deleteObjects(java.lang.String collection,
com.mongodb.DBObject query)
Deletes the objects matching the given query from
the given collection.
|
void |
deleteObjects(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.WriteConcern concern)
Deletes the objects matching the given query from
the given collection.
|
void |
deleteObjects(java.lang.String collection,
java.lang.Object[] ids)
Deletes the objects matching the given query from
the given collection.
|
void |
deleteObjects(java.lang.String collection,
java.lang.Object[] ids,
com.mongodb.WriteConcern concern)
Deletes the objects matching the given query from
the given collection.
|
void |
deletePartialObject(java.lang.String collection,
com.mongodb.DBObject query,
java.lang.String name)
Deletes a partial object.
|
void |
deletePartialObject(java.lang.String collection,
com.mongodb.DBObject query,
java.lang.String name,
com.mongodb.WriteConcern concern)
Deletes a partial object.
|
void |
deletePartialObject(java.lang.String collection,
java.lang.Object id,
java.lang.String name)
Deletes a partial object.
|
void |
deletePartialObject(java.lang.String collection,
java.lang.Object id,
java.lang.String name,
com.mongodb.WriteConcern concern)
Deletes a partial object.
|
void |
ensureIndex(java.lang.String collection,
com.mongodb.DBObject keys,
boolean background,
boolean unique,
boolean dropDupes)
Ensures that an index exists on the given collection.
|
void |
ensureIndex(java.lang.String collection,
java.lang.String key,
boolean background,
boolean unique,
boolean dropDupes)
Ensures that an index exists on the given collection.
|
com.mongodb.CommandResult |
executeCommand(com.mongodb.DBObject cmd)
Executes the given command.
|
com.mongodb.CommandResult |
executeCommand(java.lang.String cmd)
Executes the given command.
|
<T> T |
findAndDelete(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.DBObject sort,
java.lang.Class<T> clazz)
Finds and removes the first object matching the query from
the given collection and returns it.
|
<T> T |
findAndDelete(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.DBObject sort,
java.lang.Class<T> clazz,
java.lang.String[] fields)
Finds and removes the first object matching the query from
the given collection and returns it.
|
<T> T |
findAndModify(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.DBObject sort,
com.mongodb.DBObject update,
boolean returnNew,
boolean upsert,
java.lang.Class<T> clazz)
Performs a find and modify.
|
<T> T |
findAndModify(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.DBObject sort,
com.mongodb.DBObject update,
boolean returnNew,
boolean upsert,
java.lang.Class<T> clazz,
java.lang.String[] fields)
Performs a find and modify.
|
<T> ObjectIterator<T> |
findByExample(java.lang.String collection,
T example,
java.lang.Class<T> clazz)
Finds objects by the given example in the given
collection and returns an
ObjectIterator
for them. |
<T> T |
findObject(java.lang.String collection,
com.mongodb.DBObject query,
java.lang.Class<T> clazz)
Maps and returns a single object matching the given query
from the given collection.
|
<T> ObjectIterator<T> |
findObjects(java.lang.String collection,
com.mongodb.DBObject query,
java.lang.Class<T> clazz)
Maps and returns an
ObjectIterator for objects
matching the given query in the given collection. |
com.mongodb.DBCollection |
getCollection(java.lang.String name)
Returns a
DBCollection by it's name. |
com.mongodb.DB |
getDB()
Returns the underlying
DB. |
<T> T |
getPartialObject(java.lang.String collection,
com.mongodb.DBObject query,
java.lang.String name,
java.lang.Class<T> clazz)
Returns a partial object.
|
<T> T |
getPartialObject(java.lang.String collection,
java.lang.Object id,
java.lang.String name,
java.lang.Class<T> clazz)
Returns a partial object.
|
MapReduceResult |
mapReduce(java.lang.String collection,
MapReduce mapReduce)
Executes a MapReduce job using the given
MapReduceConfiguration. |
<T> T |
readObject(java.lang.String collection,
java.lang.Object id,
java.lang.Class<T> clazz)
Maps and returns an object from the given collection.
|
<T> T[] |
readObjects(java.lang.String collection,
java.lang.Object[] ids,
java.lang.Class<T> clazz)
Maps and returns a objects from the given collection.
|
<T> void |
savePartialObject(java.lang.String collection,
com.mongodb.DBObject query,
java.lang.String name,
T data,
boolean upsert) |
<T> void |
savePartialObject(java.lang.String collection,
com.mongodb.DBObject query,
java.lang.String name,
T data,
boolean upsert,
com.mongodb.WriteConcern concern)
Saves a partial object.
|
<T> void |
savePartialObject(java.lang.String collection,
java.lang.Object id,
java.lang.String name,
T data,
boolean upsert)
Saves a partial object.
|
<T> void |
savePartialObject(java.lang.String collection,
java.lang.Object id,
java.lang.String name,
T data,
boolean upsert,
com.mongodb.WriteConcern concern)
Saves a partial object.
|
void |
setDb(com.mongodb.DB db) |
void |
setObjectMapper(ObjectMapper objectMapper) |
void |
update(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.DBObject update,
boolean upsert,
boolean multi) |
void |
update(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.DBObject update,
boolean upsert,
boolean multi,
com.mongodb.WriteConcern concern) |
void |
update(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.DBObject update,
boolean upsert,
boolean multi,
com.mongodb.WriteConcern concern,
com.mongodb.DBEncoder encoder) |
void |
updateObject(java.lang.String collection,
java.lang.Object id,
java.lang.Object o)
Updates the object with the given id in the given
collection.
|
void |
updateObject(java.lang.String collection,
java.lang.Object id,
java.lang.Object o,
com.mongodb.WriteConcern concern)
Updates the object with the given id in the given
collection.
|
public MongoDaoImpl(com.mongodb.DB db,
ObjectMapper objectMapper)
MongoDaoImpl.db - the DBobjectMapper - the ObjectMapperpublic MongoDaoImpl()
MongoDaoImpl.public Statement createStatement(java.lang.String mql)
Statement from the given mql code
and returns it.createStatement in interface MongoDaomql - the MQL codeStatementpublic DaoQuery createQuery()
DaoQuery and returns it.createQuery in interface MongoDaoDaoQuerypublic long countObjects(java.lang.String collection,
com.mongodb.DBObject query)
countObjects in interface MongoDaocollection - the collectionquery - the querypublic <T> T createObject(java.lang.String collection,
T object,
com.mongodb.WriteConcern concern)
createObject in interface MongoDaoT - the typecollection - the collectionobject - the object to createconcern - the WriteConcernpublic <T> T createObject(java.lang.String collection,
T object)
createObject in interface MongoDaoT - the typecollection - the collectionobject - the object to createpublic <T> T[] createObjects(java.lang.String collection,
T[] objects)
createObjects in interface MongoDaoT - the typecollection - the collectionobjects - the objects to createpublic <T> T[] createObjects(java.lang.String collection,
T[] objects,
com.mongodb.WriteConcern concern)
createObjects in interface MongoDaoT - the typecollection - the collectionobjects - the objects to createconcern - the WriteConcernpublic void deleteObject(java.lang.String collection,
java.lang.Object id,
com.mongodb.WriteConcern concern)
deleteObject in interface MongoDaocollection - the collectionid - the idpublic void deleteObject(java.lang.String collection,
java.lang.Object id)
deleteObject in interface MongoDaocollection - the collectionid - the idpublic void deleteObjects(java.lang.String collection,
java.lang.Object[] ids,
com.mongodb.WriteConcern concern)
deleteObjects in interface MongoDaocollection - the collectionids - the ids of the objects to deletepublic void deleteObjects(java.lang.String collection,
java.lang.Object[] ids)
deleteObjects in interface MongoDaocollection - the collectionids - the ids of the objects to deletepublic void deleteObjects(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.WriteConcern concern)
deleteObjects in interface MongoDaocollection - the collectionquery - the querypublic void deleteObjects(java.lang.String collection,
com.mongodb.DBObject query)
deleteObjects in interface MongoDaocollection - the collectionquery - the querypublic <T> T getPartialObject(java.lang.String collection,
java.lang.Object id,
java.lang.String name,
java.lang.Class<T> clazz)
getPartialObject in interface MongoDaoT - the partial object typecollection - the collectionid - the document's idname - the nameclazz - the typepublic <T> T getPartialObject(java.lang.String collection,
com.mongodb.DBObject query,
java.lang.String name,
java.lang.Class<T> clazz)
getPartialObject in interface MongoDaoT - the partial object typecollection - the collectionquery - the queryname - the nameclazz - the typepublic <T> void savePartialObject(java.lang.String collection,
java.lang.Object id,
java.lang.String name,
T data,
boolean upsert,
com.mongodb.WriteConcern concern)
savePartialObject in interface MongoDaoT - the partial object typecollection - the collectionid - the document's idname - the namedata - the data to saveupsert - the upsertpublic <T> void savePartialObject(java.lang.String collection,
java.lang.Object id,
java.lang.String name,
T data,
boolean upsert)
savePartialObject in interface MongoDaoT - the partial object typecollection - the collectionid - the document's idname - the namedata - the data to saveupsert - the upsertpublic <T> void savePartialObject(java.lang.String collection,
com.mongodb.DBObject query,
java.lang.String name,
T data,
boolean upsert)
public <T> void savePartialObject(java.lang.String collection,
com.mongodb.DBObject query,
java.lang.String name,
T data,
boolean upsert,
com.mongodb.WriteConcern concern)
savePartialObject in interface MongoDaoT - the partial object typecollection - the collectionquery - the queryname - the namedata - the data to saveupsert - the upsertpublic void deletePartialObject(java.lang.String collection,
com.mongodb.DBObject query,
java.lang.String name,
com.mongodb.WriteConcern concern)
deletePartialObject in interface MongoDaocollection - the collectionquery - the queryname - the namepublic void deletePartialObject(java.lang.String collection,
com.mongodb.DBObject query,
java.lang.String name)
deletePartialObject in interface MongoDaocollection - the collectionquery - the queryname - the namepublic void deletePartialObject(java.lang.String collection,
java.lang.Object id,
java.lang.String name,
com.mongodb.WriteConcern concern)
deletePartialObject in interface MongoDaocollection - the collectionid - the document's idname - the namepublic void deletePartialObject(java.lang.String collection,
java.lang.Object id,
java.lang.String name)
deletePartialObject in interface MongoDaocollection - the collectionid - the document's idname - the namepublic <T> ObjectIterator<T> findByExample(java.lang.String collection, T example, java.lang.Class<T> clazz)
ObjectIterator
for them.findByExample in interface MongoDaoT - the object typecollection - the collectionexample - the exampleclazz - the classObjectIteratorpublic <T> T findObject(java.lang.String collection,
com.mongodb.DBObject query,
java.lang.Class<T> clazz)
findObject in interface MongoDaoT - the typecollection - the collectionquery - the queryclazz - the java type to map the objects topublic <T> ObjectIterator<T> findObjects(java.lang.String collection, com.mongodb.DBObject query, java.lang.Class<T> clazz)
ObjectIterator for objects
matching the given query in the given collection.findObjects in interface MongoDaoT - the typecollection - the collectionquery - the queryclazz - the java type to map the objects toObjectIteratorpublic com.mongodb.DBCollection getCollection(java.lang.String name)
DBCollection by it's name.getCollection in interface MongoDaoname - the nameDBCollectionpublic com.mongodb.DB getDB()
DB.public <T> T readObject(java.lang.String collection,
java.lang.Object id,
java.lang.Class<T> clazz)
readObject in interface MongoDaoT - the typecollection - the collectionid - the object's idclazz - the object's classpublic <T> T[] readObjects(java.lang.String collection,
java.lang.Object[] ids,
java.lang.Class<T> clazz)
readObjects in interface MongoDaoT - the typecollection - the collectionids - the object's idclazz - the object's classpublic void updateObject(java.lang.String collection,
java.lang.Object id,
java.lang.Object o,
com.mongodb.WriteConcern concern)
updateObject in interface MongoDaocollection - the collectionid - the ido - the objectpublic void updateObject(java.lang.String collection,
java.lang.Object id,
java.lang.Object o)
updateObject in interface MongoDaocollection - the collectionid - the ido - the objectpublic com.mongodb.CommandResult executeCommand(com.mongodb.DBObject cmd)
executeCommand in interface MongoDaocmd - the command to executepublic com.mongodb.CommandResult executeCommand(java.lang.String cmd)
executeCommand in interface MongoDaocmd - the command to executepublic void ensureIndex(java.lang.String collection,
java.lang.String key,
boolean background,
boolean unique,
boolean dropDupes)
ensureIndex in interface MongoDaocollection - the collectionkey - the keybackground - whether or not to build the index in the backgroundunique - if it's a unique indexdropDupes - whether or not to drop duplicate documentspublic void ensureIndex(java.lang.String collection,
com.mongodb.DBObject keys,
boolean background,
boolean unique,
boolean dropDupes)
ensureIndex in interface MongoDaocollection - the collectionkeys - the keysbackground - whether or not to build the index in the backgroundunique - if it's a unique indexdropDupes - whether or not to drop duplicate documentspublic MapReduceResult mapReduce(java.lang.String collection, MapReduce mapReduce)
MapReduceConfiguration.public <T> T findAndDelete(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.DBObject sort,
java.lang.Class<T> clazz,
java.lang.String[] fields)
findAndDelete in interface MongoDaocollection - the collectionquery - the queryclazz - the classfields - the fields to populate in the return objectpublic <T> T findAndDelete(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.DBObject sort,
java.lang.Class<T> clazz)
findAndDelete in interface MongoDaocollection - the collectionquery - the queryclazz - the classpublic <T> T findAndModify(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.DBObject sort,
com.mongodb.DBObject update,
boolean returnNew,
boolean upsert,
java.lang.Class<T> clazz,
java.lang.String[] fields)
findAndModify in interface MongoDaocollection - the collectionquery - the querysort - the sort optionupdate - the update objectreturnNew - whether or not to return the new or old valueupsert - create if it doesn't existclazz - the typefields - the fields to populate in the return objectpublic <T> T findAndModify(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.DBObject sort,
com.mongodb.DBObject update,
boolean returnNew,
boolean upsert,
java.lang.Class<T> clazz)
findAndModify in interface MongoDaocollection - the collectionquery - the querysort - the sort optionupdate - the update objectreturnNew - whether or not to return the new or old valueupsert - create if it doesn't existclazz - the typepublic void update(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.DBObject update,
boolean upsert,
boolean multi,
com.mongodb.WriteConcern concern,
com.mongodb.DBEncoder encoder)
public void update(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.DBObject update,
boolean upsert,
boolean multi,
com.mongodb.WriteConcern concern)
public void update(java.lang.String collection,
com.mongodb.DBObject query,
com.mongodb.DBObject update,
boolean upsert,
boolean multi)
public void setDb(com.mongodb.DB db)
db - the db to setpublic void setObjectMapper(ObjectMapper objectMapper)
objectMapper - the objectMapper to setCopyright © 2013. All Rights Reserved.