net.vz.mongodb.jackson
Class JacksonDBCollection<T,K>

java.lang.Object
  extended by net.vz.mongodb.jackson.JacksonDBCollection<T,K>

public class JacksonDBCollection<T,K>
extends Object

A DBCollection that marshals/demarshals objects to/from Jackson annotated classes. It provides a very thin wrapper over an existing DBCollection.

Since:
1.0
Author:
James Roper

Nested Class Summary
static class JacksonDBCollection.Feature
           
 
Constructor Summary
protected JacksonDBCollection(com.mongodb.DBCollection dbCollection, org.codehaus.jackson.type.JavaType type, org.codehaus.jackson.type.JavaType keyType, org.codehaus.jackson.map.ObjectMapper objectMapper, Map<JacksonDBCollection.Feature,Boolean> features)
           
 
Method Summary
 void addOption(int option)
          adds a default query option
 K convertFromDbId(Object object)
           
 long count()
          returns the number of documents in this collection.
 long count(com.mongodb.DBObject query)
          returns the number of documents that match a query.
 void createIndex(com.mongodb.DBObject keys)
          calls DBCollection.createIndex(com.mongodb.DBObject, com.mongodb.DBObject) with default index options
 void createIndex(com.mongodb.DBObject keys, com.mongodb.DBObject options)
          Forces creation of an index on a set of fields, if one does not already exist.
 JacksonDBCollection<T,K> disable(JacksonDBCollection.Feature feature)
          Disable the given feature
 List distinct(String key)
          find distinct values for a key
 List distinct(String key, com.mongodb.DBObject query)
          find distinct values for a key
 void drop()
          Drops (deletes) this collection.
 void dropIndex(com.mongodb.DBObject keys)
          Drops an index from this collection
 void dropIndex(String name)
          Drops an index from this collection
 void dropIndexes()
          Drops all indices from this collection
 void dropIndexes(String name)
          Drops an index from this collection
 JacksonDBCollection<T,K> enable(JacksonDBCollection.Feature feature)
          Enable the given feature
 void ensureIndex(com.mongodb.DBObject keys)
          calls DBCollection.ensureIndex(com.mongodb.DBObject, com.mongodb.DBObject) with default options
 void ensureIndex(com.mongodb.DBObject keys, com.mongodb.DBObject optionsIN)
          Creates an index on a set of fields, if one does not already exist.
 void ensureIndex(com.mongodb.DBObject keys, String name)
          calls DBCollection.ensureIndex(com.mongodb.DBObject, java.lang.String, boolean) with unique=false
 void ensureIndex(com.mongodb.DBObject keys, String name, boolean unique)
          Ensures an index on this collection (that is, the index will be created if it does not exist).
 void ensureIndex(String name)
          Creates an ascending index on a field with default options, if one does not already exist.
 boolean equals(Object o)
           
<R,RK> List<R>
fetch(Collection<DBRef<R,RK>> collection)
          Fetch a collection of dbrefs.
<R,RK> List<R>
fetch(Collection<DBRef<R,RK>> collection, com.mongodb.DBObject fields)
          Fetch a collection of dbrefs.
 DBCursor<T> find()
          Queries for all objects in this collection.
 DBCursor<T> find(com.mongodb.DBObject query)
          Queries for an object in this collection.
 DBCursor<T> find(com.mongodb.DBObject query, com.mongodb.DBObject keys)
          Queries for an object in this collection.
 DBCursor<T> find(T query)
          Queries for an object in this collection.
 DBCursor<T> find(T query, T keys)
          Queries for an object in this collection.
 T findAndModify(com.mongodb.DBObject query, com.mongodb.DBObject update)
          calls DBCollection.findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, boolean, com.mongodb.DBObject, boolean, boolean) with fields=null, sort=null, remove=false, returnNew=false, upsert=false
 T findAndModify(com.mongodb.DBObject query, com.mongodb.DBObject sort, com.mongodb.DBObject update)
          calls DBCollection.findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, boolean, com.mongodb.DBObject, boolean, boolean) with fields=null, remove=false, returnNew=false, upsert=false
 T findAndModify(com.mongodb.DBObject query, com.mongodb.DBObject fields, com.mongodb.DBObject sort, boolean remove, com.mongodb.DBObject update, boolean returnNew, boolean upsert)
          Finds the first document in the query and updates it.
 T findAndRemove(com.mongodb.DBObject query)
          calls DBCollection.findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, boolean, com.mongodb.DBObject, boolean, boolean) with fields=null, sort=null, remove=true, returnNew=false, upsert=false
 T findOne()
          Returns a single object from this collection.
 T findOne(com.mongodb.DBObject query)
          Returns a single object from this collection matching the query.
 T findOne(com.mongodb.DBObject query, com.mongodb.DBObject fields)
          Returns a single object from this collection matching the query.
 T findOne(com.mongodb.DBObject query, com.mongodb.DBObject fields, com.mongodb.ReadPreference readPref)
          Returns a single object from this collection matching the query.
 T findOne(T query)
          Returns a single object from this collection matching the query.
 T findOne(T query, T fields)
          Returns a single object from this collection matching the query.
 T findOne(T query, T fields, com.mongodb.ReadPreference readPref)
          Returns a single object from this collection matching the query.
 T findOneById(K id)
          Find an object by the given id
 T findOneById(K id, com.mongodb.DBObject fields)
          Find an object by the given id
 T findOneById(K id, T fields)
          Find an object by the given id
<S,L> JacksonDBCollection<S,L>
getCollection(String n, Class<S> type, Class<L> keyType)
          Finds a collection that is prefixed with this collection's name.
 JacksonCollectionKey getCollectionKey()
          Get the type of this collection
 long getCount()
          calls DBCollection.getCount(com.mongodb.DBObject, com.mongodb.DBObject) with an empty query and null fields.
 long getCount(com.mongodb.DBObject query)
          calls DBCollection.getCount(com.mongodb.DBObject, com.mongodb.DBObject) with null fields.
 long getCount(com.mongodb.DBObject query, com.mongodb.DBObject fields)
          calls DBCollection.getCount(com.mongodb.DBObject, com.mongodb.DBObject, long, long) with limit=0 and skip=0
 long getCount(com.mongodb.DBObject query, com.mongodb.DBObject fields, long limit, long skip)
          Returns the number of documents in the collection that match the specified query
 long getCount(T query)
          calls DBCollection.getCount(com.mongodb.DBObject, com.mongodb.DBObject) with null fields.
 long getCount(T query, T fields)
          calls DBCollection.getCount(com.mongodb.DBObject, com.mongodb.DBObject, long, long) with limit=0 and skip=0
 long getCount(T query, T fields, long limit, long skip)
          Returns the number of documents in the collection that match the specified query
 com.mongodb.DB getDB()
          Returns the database this collection is a member of.
 com.mongodb.DBCollection getDbCollection()
          Get the underlying db collection
 String getFullName()
          Returns the full name of this collection, with the database name as a prefix.
 List<com.mongodb.DBObject> getIndexInfo()
          Return a list of the indexes for this collection.
 String getName()
          Returns the name of this collection.
 int getOptions()
          gets the default query options
 com.mongodb.ReadPreference getReadPreference()
          Gets the read preference
<T,K> JacksonDBCollection<T,K>
getReferenceCollection(JacksonCollectionKey collectionKey)
          Get a collection for loading a reference of the given type
<T,K> JacksonDBCollection<T,K>
getReferenceCollection(String collectionName, org.codehaus.jackson.type.JavaType type, org.codehaus.jackson.type.JavaType keyType)
          Get a collection for loading a reference of the given type
 com.mongodb.CommandResult getStats()
          gets the collections statistics ("collstats" command)
 com.mongodb.WriteConcern getWriteConcern()
          Get the write concern for this collection.
 com.mongodb.DBObject group(com.mongodb.DBObject key, com.mongodb.DBObject cond, com.mongodb.DBObject initial, String reduce)
          calls DBCollection.group(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, java.lang.String, java.lang.String) with finalize=null
 com.mongodb.DBObject group(com.mongodb.DBObject key, com.mongodb.DBObject cond, com.mongodb.DBObject initial, String reduce, String finalize)
          Applies a group operation
 com.mongodb.DBObject group(com.mongodb.GroupCommand cmd)
          Applies a group operation
 int hashCode()
           
 WriteResult<T,K> insert(List<T> list)
          Inserts objects into the database.
 WriteResult<T,K> insert(List<T> list, com.mongodb.WriteConcern concern)
          Inserts objects into the database.
 WriteResult<T,K> insert(T... objects)
          Inserts objects into the database.
 WriteResult<T,K> insert(T object)
          Inserts an object into the database.
 WriteResult<T,K> insert(T object, com.mongodb.WriteConcern concern)
          Inserts an object into the database.
 WriteResult<T,K> insert(com.mongodb.WriteConcern concern, T... objects)
          Inserts objects into the database.
 boolean isCapped()
          returns whether or not this is a capped collection
 boolean isEnabled(JacksonDBCollection.Feature feature)
          Whether the given feature is enabled
 com.mongodb.MapReduceOutput mapReduce(com.mongodb.DBObject command)
          Deprecated. 
<S,L> MapReduceOutput<S,L>
mapReduce(MapReduce.MapReduceCommand<S,L> command)
          Performs a map reduce operation
 com.mongodb.MapReduceOutput mapReduce(com.mongodb.MapReduceCommand command)
          Deprecated. 
 com.mongodb.MapReduceOutput mapReduce(String map, String reduce, String outputTarget, com.mongodb.DBObject query)
          Deprecated. 
 com.mongodb.MapReduceOutput mapReduce(String map, String reduce, String outputTarget, com.mongodb.MapReduceCommand.OutputType outputType, com.mongodb.DBObject query)
          Deprecated. 
 WriteResult<T,K> remove(com.mongodb.DBObject query)
          calls DBCollection.remove(com.mongodb.DBObject, com.mongodb.WriteConcern) with the default WriteConcern
 WriteResult<T,K> remove(com.mongodb.DBObject query, com.mongodb.WriteConcern concern)
          Removes objects from the database collection.
 WriteResult<T,K> remove(T object)
          calls DBCollection.remove(com.mongodb.DBObject, com.mongodb.WriteConcern) with the default WriteConcern
 WriteResult<T,K> remove(T object, com.mongodb.WriteConcern concern)
          Removes objects from the database collection.
 WriteResult<T,K> removeById(K id)
          calls DBCollection.remove(com.mongodb.DBObject, com.mongodb.WriteConcern) with the default WriteConcern
 JacksonDBCollection<T,K> rename(String newName)
          Calls DBCollection.rename(java.lang.String, boolean) with dropTarget=false
 JacksonDBCollection<T,K> rename(String newName, boolean dropTarget)
          renames of this collection to newName
 void resetIndexCache()
          Clears all indices that have not yet been applied to this collection.
 void resetOptions()
          resets the default query options
 WriteResult<T,K> save(T object)
          calls DBCollection.save(com.mongodb.DBObject, com.mongodb.WriteConcern) with default WriteConcern
 WriteResult<T,K> save(T object, com.mongodb.WriteConcern concern)
          Saves an object to this collection (does insert or update based on the object _id).
 void setHintFields(List<com.mongodb.DBObject> lst)
          Set hint fields for this collection (to optimize queries).
 void setOptions(int options)
          sets the default query options
 void setReadPreference(com.mongodb.ReadPreference preference)
          Sets the read preference for this collection.
 void setWriteConcern(com.mongodb.WriteConcern concern)
          Set the write concern for this collection.
 String toString()
           
 WriteResult<T,K> update(com.mongodb.DBObject query, com.mongodb.DBObject object)
          calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=false
 WriteResult<T,K> update(com.mongodb.DBObject query, com.mongodb.DBObject object, boolean upsert, boolean multi)
          calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean, com.mongodb.WriteConcern) with default WriteConcern.
 WriteResult<T,K> update(com.mongodb.DBObject query, com.mongodb.DBObject object, boolean upsert, boolean multi, com.mongodb.WriteConcern concern)
          Performs an update operation.
 WriteResult<T,K> update(com.mongodb.DBObject query, DBUpdate.Builder update)
          Performs an update operation.
 WriteResult<T,K> update(com.mongodb.DBObject query, DBUpdate.Builder update, boolean upsert, boolean multi)
          Performs an update operation.
 WriteResult<T,K> update(com.mongodb.DBObject query, DBUpdate.Builder update, boolean upsert, boolean multi, com.mongodb.WriteConcern concern)
          Performs an update operation.
 WriteResult<T,K> update(T query, T object)
          calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=false
 WriteResult<T,K> update(T query, T object, boolean upsert, boolean multi)
          calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean, com.mongodb.WriteConcern) with default WriteConcern.
 WriteResult<T,K> update(T query, T object, boolean upsert, boolean multi, com.mongodb.WriteConcern concern)
          Performs an update operation.
 WriteResult<T,K> updateById(K id, DBUpdate.Builder update)
          Performs an update operation.
 WriteResult<T,K> updateById(K id, T object)
          calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=false
 WriteResult<T,K> updateMulti(com.mongodb.DBObject query, com.mongodb.DBObject object)
          calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=true
 WriteResult<T,K> updateMulti(com.mongodb.DBObject query, DBUpdate.Builder update)
          calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=true
 WriteResult<T,K> updateMulti(T query, T object)
          calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=true
static
<T> JacksonDBCollection<T,Object>
wrap(com.mongodb.DBCollection dbCollection, Class<T> type)
          Wraps a DB collection in a JacksonDBCollection
static
<T,K> JacksonDBCollection<T,K>
wrap(com.mongodb.DBCollection dbCollection, Class<T> type, Class<K> keyType)
          Wraps a DB collection in a JacksonDBCollection
static
<T,K> JacksonDBCollection<T,K>
wrap(com.mongodb.DBCollection dbCollection, Class<T> type, Class<K> keyType, Class<?> view)
          Wraps a DB collection in a JacksonDBCollection
static
<T,K> JacksonDBCollection<T,K>
wrap(com.mongodb.DBCollection dbCollection, Class<T> type, Class<K> keyType, org.codehaus.jackson.map.ObjectMapper objectMapper)
          Wraps a DB collection in a JacksonDBCollection, using the given object mapper.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JacksonDBCollection

protected JacksonDBCollection(com.mongodb.DBCollection dbCollection,
                              org.codehaus.jackson.type.JavaType type,
                              org.codehaus.jackson.type.JavaType keyType,
                              org.codehaus.jackson.map.ObjectMapper objectMapper,
                              Map<JacksonDBCollection.Feature,Boolean> features)
Method Detail

wrap

public static <T> JacksonDBCollection<T,Object> wrap(com.mongodb.DBCollection dbCollection,
                                                     Class<T> type)
Wraps a DB collection in a JacksonDBCollection

Parameters:
dbCollection - The DB collection to wrap
type - The type of objects to deserialise to
Returns:
The wrapped collection

wrap

public static <T,K> JacksonDBCollection<T,K> wrap(com.mongodb.DBCollection dbCollection,
                                                  Class<T> type,
                                                  Class<K> keyType)
Wraps a DB collection in a JacksonDBCollection

Parameters:
dbCollection - The DB collection to wrap
type - The type of objects to deserialise to
keyType - The type of the objects key
Returns:
The wrapped collection

wrap

public static <T,K> JacksonDBCollection<T,K> wrap(com.mongodb.DBCollection dbCollection,
                                                  Class<T> type,
                                                  Class<K> keyType,
                                                  Class<?> view)
Wraps a DB collection in a JacksonDBCollection

Parameters:
dbCollection - The DB collection to wrap
type - The type of objects to deserialise to
keyType - The type of the objects key
view - The JSON view to use for serialisation
Returns:
The wrapped collection

wrap

public static <T,K> JacksonDBCollection<T,K> wrap(com.mongodb.DBCollection dbCollection,
                                                  Class<T> type,
                                                  Class<K> keyType,
                                                  org.codehaus.jackson.map.ObjectMapper objectMapper)
Wraps a DB collection in a JacksonDBCollection, using the given object mapper. JacksonDBCollection requires a specially configured object mapper to work. It does not automatically configure the object mapper passed into this method, because the same object mapper might be passed into multiple calls to this method. Consequently, it is up to the caller to ensure that the object mapper has been configured for use by JacksonDBCollection. This can be done by passing the object mapper to MongoJacksonMapperModule.configure(org.codehaus.jackson.map.ObjectMapper).

Parameters:
dbCollection - The DB collection to wrap
type - The type of objects to deserialise to
objectMapper - The ObjectMapper to configure.
Returns:
The wrapped collection

enable

public JacksonDBCollection<T,K> enable(JacksonDBCollection.Feature feature)
Enable the given feature

Parameters:
feature - The feature to enable
Returns:
this object

disable

public JacksonDBCollection<T,K> disable(JacksonDBCollection.Feature feature)
Disable the given feature

Parameters:
feature - The feature to disable
Returns:
this object

isEnabled

public boolean isEnabled(JacksonDBCollection.Feature feature)
Whether the given feature is enabled

Parameters:
feature - The feature to check
Returns:
whether it is enabled

getDbCollection

public com.mongodb.DBCollection getDbCollection()
Get the underlying db collection

Returns:
The underlying db collection

insert

public WriteResult<T,K> insert(T object)
                        throws com.mongodb.MongoException
Inserts an object into the database. if the objects _id is null, one will be generated you can get the _id that was generated by calling getSavedObject() or getSavedId() on the result

Parameters:
object - The object to insert
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

insert

public WriteResult<T,K> insert(T object,
                               com.mongodb.WriteConcern concern)
                        throws com.mongodb.MongoException
Inserts an object into the database. if the objects _id is null, one will be generated you can get the _id that was generated by calling getSavedObject() or getSavedId() on the result

Parameters:
object - The object to insert
concern - the write concern
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

insert

public WriteResult<T,K> insert(T... objects)
                        throws com.mongodb.MongoException
Inserts objects into the database. if the objects _id is null, one will be generated you can get the _id that were generated by calling getSavedObjects() or getSavedIds() on the result

Parameters:
objects - The objects to insert
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

insert

public WriteResult<T,K> insert(com.mongodb.WriteConcern concern,
                               T... objects)
                        throws com.mongodb.MongoException
Inserts objects into the database. if the objects _id is null, one will be generated you can get the _id that were generated by calling getSavedObjects() or getSavedIds() on the result

Parameters:
objects - The objects to insert
concern - the write concern
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

insert

public WriteResult<T,K> insert(List<T> list)
                        throws com.mongodb.MongoException
Inserts objects into the database. if the objects _id is null, one will be generated you can get the _id that were generated by calling getSavedObjects() or getSavedIds() on the result

Parameters:
list - The objects to insert
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

insert

public WriteResult<T,K> insert(List<T> list,
                               com.mongodb.WriteConcern concern)
                        throws com.mongodb.MongoException
Inserts objects into the database. if the objects _id is null, one will be generated you can get the _id that were generated by calling getSavedObjects() or getSavedIds() on the result

Parameters:
list - The objects to insert
concern - the write concern
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

update

public WriteResult<T,K> update(com.mongodb.DBObject query,
                               com.mongodb.DBObject object,
                               boolean upsert,
                               boolean multi,
                               com.mongodb.WriteConcern concern)
                        throws com.mongodb.MongoException
Performs an update operation.

Parameters:
query - search query for old object to update
object - object with which to update query
upsert - if the database should create the element if it does not exist
multi - if the update should be applied to all objects matching (db version 1.1.3 and above). An object will not be inserted if it does not exist in the collection and upsert=true and multi=true. See http://www.mongodb.org/display/DOCS/Atomic+Operations
concern - the write concern
Returns:
The write result
Throws:
com.mongodb.MongoException - If an error occurred

update

public WriteResult<T,K> update(com.mongodb.DBObject query,
                               DBUpdate.Builder update,
                               boolean upsert,
                               boolean multi,
                               com.mongodb.WriteConcern concern)
                        throws com.mongodb.MongoException
Performs an update operation.

Parameters:
query - search query for old object to update
update - update with which to update query
upsert - if the database should create the element if it does not exist
multi - if the update should be applied to all objects matching (db version 1.1.3 and above). An object will not be inserted if it does not exist in the collection and upsert=true and multi=true. See http://www.mongodb.org/display/DOCS/Atomic+Operations
concern - the write concern
Returns:
The write result
Throws:
com.mongodb.MongoException - If an error occurred

update

public WriteResult<T,K> update(T query,
                               T object,
                               boolean upsert,
                               boolean multi,
                               com.mongodb.WriteConcern concern)
                        throws com.mongodb.MongoException
Performs an update operation.

Parameters:
query - search query for old object to update
object - object with which to update query
upsert - if the database should create the element if it does not exist
multi - if the update should be applied to all objects matching (db version 1.1.3 and above). An object will not be inserted if it does not exist in the collection and upsert=true and multi=true. See http://www.mongodb.org/display/DOCS/Atomic+Operations
concern - the write concern
Returns:
The write result
Throws:
com.mongodb.MongoException - If an error occurred

update

public WriteResult<T,K> update(com.mongodb.DBObject query,
                               com.mongodb.DBObject object,
                               boolean upsert,
                               boolean multi)
                        throws com.mongodb.MongoException
calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean, com.mongodb.WriteConcern) with default WriteConcern.

Parameters:
query - search query for old object to update
object - object with which to update q
upsert - if the database should create the element if it does not exist
multi - if the update should be applied to all objects matching (db version 1.1.3 and above) See http://www.mongodb.org/display/DOCS/Atomic+Operations
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

update

public WriteResult<T,K> update(com.mongodb.DBObject query,
                               DBUpdate.Builder update,
                               boolean upsert,
                               boolean multi)
                        throws com.mongodb.MongoException
Performs an update operation.

Parameters:
query - search query for old object to update
update - update with which to update query
upsert - if the database should create the element if it does not exist
multi - if the update should be applied to all objects matching (db version 1.1.3 and above). An object will not be inserted if it does not exist in the collection and upsert=true and multi=true. See http://www.mongodb.org/display/DOCS/Atomic+Operations
Returns:
The write result
Throws:
com.mongodb.MongoException - If an error occurred

update

public WriteResult<T,K> update(T query,
                               T object,
                               boolean upsert,
                               boolean multi)
                        throws com.mongodb.MongoException
calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean, com.mongodb.WriteConcern) with default WriteConcern.

Parameters:
query - search query for old object to update
object - object with which to update q
upsert - if the database should create the element if it does not exist
multi - if the update should be applied to all objects matching (db version 1.1.3 and above) See http://www.mongodb.org/display/DOCS/Atomic+Operations
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

update

public WriteResult<T,K> update(com.mongodb.DBObject query,
                               com.mongodb.DBObject object)
                        throws com.mongodb.MongoException
calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=false

Parameters:
query - search query for old object to update
object - object with which to update query
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

update

public WriteResult<T,K> update(com.mongodb.DBObject query,
                               DBUpdate.Builder update)
                        throws com.mongodb.MongoException
Performs an update operation.

Parameters:
query - search query for old object to update
update - update with which to update query
Returns:
The write result
Throws:
com.mongodb.MongoException - If an error occurred

update

public WriteResult<T,K> update(T query,
                               T object)
                        throws com.mongodb.MongoException
calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=false

Parameters:
query - search query for old object to update
object - object with which to update query
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

updateById

public WriteResult<T,K> updateById(K id,
                                   T object)
                            throws com.mongodb.MongoException
calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=false

Parameters:
id - the id of the object to update
object - object with which to update query
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

updateById

public WriteResult<T,K> updateById(K id,
                                   DBUpdate.Builder update)
                            throws com.mongodb.MongoException
Performs an update operation.

Parameters:
id - The id of the document to update
update - update with which to update query
Returns:
The write result
Throws:
com.mongodb.MongoException - If an error occurred

updateMulti

public WriteResult<T,K> updateMulti(com.mongodb.DBObject query,
                                    com.mongodb.DBObject object)
                             throws com.mongodb.MongoException
calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=true

Parameters:
query - search query for old object to update
object - object with which to update query
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

updateMulti

public WriteResult<T,K> updateMulti(com.mongodb.DBObject query,
                                    DBUpdate.Builder update)
                             throws com.mongodb.MongoException
calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=true

Parameters:
query - search query for old object to update
update - update with which to update query
Returns:
The write result
Throws:
com.mongodb.MongoException - If an error occurred

updateMulti

public WriteResult<T,K> updateMulti(T query,
                                    T object)
                             throws com.mongodb.MongoException
calls DBCollection.update(com.mongodb.DBObject, com.mongodb.DBObject, boolean, boolean) with upsert=false and multi=true

Parameters:
query - search query for old object to update
object - object with which to update query
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

remove

public WriteResult<T,K> remove(com.mongodb.DBObject query,
                               com.mongodb.WriteConcern concern)
                        throws com.mongodb.MongoException
Removes objects from the database collection.

Parameters:
query - the object that documents to be removed must match
concern - WriteConcern for this operation
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

remove

public WriteResult<T,K> remove(T object,
                               com.mongodb.WriteConcern concern)
                        throws com.mongodb.MongoException
Removes objects from the database collection.

Parameters:
object - the object that documents to be removed must match
concern - WriteConcern for this operation
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

remove

public WriteResult<T,K> remove(com.mongodb.DBObject query)
                        throws com.mongodb.MongoException
calls DBCollection.remove(com.mongodb.DBObject, com.mongodb.WriteConcern) with the default WriteConcern

Parameters:
query - the query that documents to be removed must match
Returns:
The write result
Throws:
com.mongodb.MongoException - If an error occurred

remove

public WriteResult<T,K> remove(T object)
                        throws com.mongodb.MongoException
calls DBCollection.remove(com.mongodb.DBObject, com.mongodb.WriteConcern) with the default WriteConcern

Parameters:
object - the object that documents to be removed must match
Returns:
The write result
Throws:
com.mongodb.MongoException - If an error occurred

removeById

public WriteResult<T,K> removeById(K id)
                            throws com.mongodb.MongoException
calls DBCollection.remove(com.mongodb.DBObject, com.mongodb.WriteConcern) with the default WriteConcern

Parameters:
id - the id of the document to remove
Returns:
The write result
Throws:
com.mongodb.MongoException - If an error occurred

findAndModify

public T findAndModify(com.mongodb.DBObject query,
                       com.mongodb.DBObject fields,
                       com.mongodb.DBObject sort,
                       boolean remove,
                       com.mongodb.DBObject update,
                       boolean returnNew,
                       boolean upsert)
Finds the first document in the query and updates it.

Parameters:
query - query to match
fields - fields to be returned
sort - sort to apply before picking first document
remove - if true, document found will be removed
update - update to apply
returnNew - if true, the updated document is returned, otherwise the old document is returned (or it would be lost forever)
upsert - do upsert (insert if document not present)
Returns:
the object

findAndModify

public T findAndModify(com.mongodb.DBObject query,
                       com.mongodb.DBObject sort,
                       com.mongodb.DBObject update)
calls DBCollection.findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, boolean, com.mongodb.DBObject, boolean, boolean) with fields=null, remove=false, returnNew=false, upsert=false

Parameters:
query - The query
sort - The sort
update - The update to apply
Returns:
the old object

findAndModify

public T findAndModify(com.mongodb.DBObject query,
                       com.mongodb.DBObject update)
calls DBCollection.findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, boolean, com.mongodb.DBObject, boolean, boolean) with fields=null, sort=null, remove=false, returnNew=false, upsert=false

Parameters:
query - The query
update - The update to apply
Returns:
the old object

findAndRemove

public T findAndRemove(com.mongodb.DBObject query)
calls DBCollection.findAndModify(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, boolean, com.mongodb.DBObject, boolean, boolean) with fields=null, sort=null, remove=true, returnNew=false, upsert=false

Parameters:
query - The query
Returns:
the removed object

createIndex

public final void createIndex(com.mongodb.DBObject keys)
                       throws com.mongodb.MongoException
calls DBCollection.createIndex(com.mongodb.DBObject, com.mongodb.DBObject) with default index options

Parameters:
keys - an object with a key set of the fields desired for the index
Throws:
com.mongodb.MongoException - If an error occurred

createIndex

public void createIndex(com.mongodb.DBObject keys,
                        com.mongodb.DBObject options)
                 throws com.mongodb.MongoException
Forces creation of an index on a set of fields, if one does not already exist.

Parameters:
keys - The keys to index
options - The options
Throws:
com.mongodb.MongoException - If an error occurred

ensureIndex

public final void ensureIndex(String name)
Creates an ascending index on a field with default options, if one does not already exist.

Parameters:
name - name of field to index on

ensureIndex

public final void ensureIndex(com.mongodb.DBObject keys)
                       throws com.mongodb.MongoException
calls DBCollection.ensureIndex(com.mongodb.DBObject, com.mongodb.DBObject) with default options

Parameters:
keys - an object with a key set of the fields desired for the index
Throws:
com.mongodb.MongoException - If an error occurred

ensureIndex

public void ensureIndex(com.mongodb.DBObject keys,
                        String name)
                 throws com.mongodb.MongoException
calls DBCollection.ensureIndex(com.mongodb.DBObject, java.lang.String, boolean) with unique=false

Parameters:
keys - fields to use for index
name - an identifier for the index
Throws:
com.mongodb.MongoException - If an error occurred

ensureIndex

public void ensureIndex(com.mongodb.DBObject keys,
                        String name,
                        boolean unique)
                 throws com.mongodb.MongoException
Ensures an index on this collection (that is, the index will be created if it does not exist).

Parameters:
keys - fields to use for index
name - an identifier for the index. If null or empty, the default name will be used.
unique - if the index should be unique
Throws:
com.mongodb.MongoException - If an error occurred

ensureIndex

public void ensureIndex(com.mongodb.DBObject keys,
                        com.mongodb.DBObject optionsIN)
                 throws com.mongodb.MongoException
Creates an index on a set of fields, if one does not already exist.

Parameters:
keys - an object with a key set of the fields desired for the index
optionsIN - options for the index (name, unique, etc)
Throws:
com.mongodb.MongoException - If an error occurred

resetIndexCache

public void resetIndexCache()
Clears all indices that have not yet been applied to this collection.


setHintFields

public void setHintFields(List<com.mongodb.DBObject> lst)
Set hint fields for this collection (to optimize queries).

Parameters:
lst - a list of DBObjects to be used as hints

find

public DBCursor<T> find(com.mongodb.DBObject query)
                 throws com.mongodb.MongoException
Queries for an object in this collection.

Parameters:
query - object for which to search
Returns:
an iterator over the results
Throws:
com.mongodb.MongoException - If an error occurred

find

public DBCursor<T> find(T query)
                 throws com.mongodb.MongoException
Queries for an object in this collection.

Parameters:
query - object for which to search
Returns:
an iterator over the results
Throws:
com.mongodb.MongoException - If an error occurred

find

public final DBCursor<T> find(com.mongodb.DBObject query,
                              com.mongodb.DBObject keys)
Queries for an object in this collection.

An empty DBObject will match every document in the collection. Regardless of fields specified, the _id fields are always returned.

An example that returns the "x" and "_id" fields for every document in the collection that has an "x" field:

 BasicDBObject keys = new BasicDBObject();
 keys.put("x", 1);
 

DBCursor cursor = collection.find(new BasicDBObject(), keys);

Parameters:
query - object for which to search
keys - fields to return
Returns:
a cursor to iterate over results

find

public final DBCursor<T> find(T query,
                              T keys)
Queries for an object in this collection.

An empty DBObject will match every document in the collection. Regardless of fields specified, the _id fields are always returned.

To keys object should have non null values for every key that you want to return

Parameters:
query - object for which to search
keys - fields to return
Returns:
a cursor to iterate over results

find

public final DBCursor<T> find()
                       throws com.mongodb.MongoException
Queries for all objects in this collection.

Returns:
a cursor which will iterate over every object
Throws:
com.mongodb.MongoException - If an error occurred

findOne

public T findOne()
          throws com.mongodb.MongoException
Returns a single object from this collection.

Returns:
the object found, or null if the collection is empty
Throws:
com.mongodb.MongoException - If an error occurred

findOneById

public T findOneById(K id)
              throws com.mongodb.MongoException
Find an object by the given id

Parameters:
id - The id
Returns:
The object
Throws:
com.mongodb.MongoException - If an error occurred

findOneById

public T findOneById(K id,
                     com.mongodb.DBObject fields)
              throws com.mongodb.MongoException
Find an object by the given id

Parameters:
id - The id
Returns:
The object
Throws:
com.mongodb.MongoException - If an error occurred

findOneById

public T findOneById(K id,
                     T fields)
              throws com.mongodb.MongoException
Find an object by the given id

Parameters:
id - The id
Returns:
The object
Throws:
com.mongodb.MongoException - If an error occurred

findOne

public T findOne(com.mongodb.DBObject query)
          throws com.mongodb.MongoException
Returns a single object from this collection matching the query.

Parameters:
query - the query object
Returns:
the object found, or null if no such object exists
Throws:
com.mongodb.MongoException - If an error occurred

findOne

public T findOne(T query)
          throws com.mongodb.MongoException
Returns a single object from this collection matching the query.

Parameters:
query - the query object
Returns:
the object found, or null if no such object exists
Throws:
com.mongodb.MongoException - If an error occurred

findOne

public T findOne(com.mongodb.DBObject query,
                 com.mongodb.DBObject fields)
Returns a single object from this collection matching the query.

Parameters:
query - the query object
fields - the fields to return
Returns:
the object found, or null if no such object exists

findOne

public T findOne(T query,
                 T fields)
Returns a single object from this collection matching the query.

Parameters:
query - the query object
fields - an object for which every non null field will be returned
Returns:
the object found, or null if no such object exists

findOne

public T findOne(com.mongodb.DBObject query,
                 com.mongodb.DBObject fields,
                 com.mongodb.ReadPreference readPref)
Returns a single object from this collection matching the query.

Parameters:
query - the query object
fields - fields to return
readPref - The read preference
Returns:
the object found, or null if no such object exists

findOne

public T findOne(T query,
                 T fields,
                 com.mongodb.ReadPreference readPref)
Returns a single object from this collection matching the query.

Parameters:
query - the query object
fields - an object for which every non null field will be returned
readPref - The read preferences
Returns:
the object found, or null if no such object exists

fetch

public <R,RK> List<R> fetch(Collection<DBRef<R,RK>> collection)
Fetch a collection of dbrefs. This is more efficient than fetching one at a time.

Type Parameters:
R - The type of the reference
Parameters:
collection - the collection to fetch
Returns:
The collection of referenced objcets

fetch

public <R,RK> List<R> fetch(Collection<DBRef<R,RK>> collection,
                            com.mongodb.DBObject fields)
Fetch a collection of dbrefs. This is more efficient than fetching one at a time.

Parameters:
collection - the collection to fetch
fields - The fields to retrieve for each of the documents
Returns:
The collection of referenced objcets

save

public final WriteResult<T,K> save(T object)
calls DBCollection.save(com.mongodb.DBObject, com.mongodb.WriteConcern) with default WriteConcern

Parameters:
object - the object to save will add _id field to jo if needed
Returns:
The result

save

public WriteResult<T,K> save(T object,
                             com.mongodb.WriteConcern concern)
                      throws com.mongodb.MongoException
Saves an object to this collection (does insert or update based on the object _id).

Parameters:
object - the DBObject to save
concern - the write concern
Returns:
The result
Throws:
com.mongodb.MongoException - If an error occurred

dropIndexes

public void dropIndexes()
                 throws com.mongodb.MongoException
Drops all indices from this collection

Throws:
com.mongodb.MongoException - If an error occurred

dropIndexes

public void dropIndexes(String name)
                 throws com.mongodb.MongoException
Drops an index from this collection

Parameters:
name - the index name
Throws:
com.mongodb.MongoException - If an error occurred

drop

public void drop()
          throws com.mongodb.MongoException
Drops (deletes) this collection. Use with care.

Throws:
com.mongodb.MongoException - If an error occurred

count

public long count()
           throws com.mongodb.MongoException
returns the number of documents in this collection.

Returns:
The count
Throws:
com.mongodb.MongoException - If an error occurred

count

public long count(com.mongodb.DBObject query)
           throws com.mongodb.MongoException
returns the number of documents that match a query.

Parameters:
query - query to match
Returns:
The count
Throws:
com.mongodb.MongoException - If an error occurred

getCount

public long getCount()
              throws com.mongodb.MongoException
calls DBCollection.getCount(com.mongodb.DBObject, com.mongodb.DBObject) with an empty query and null fields.

Returns:
number of documents that match query
Throws:
com.mongodb.MongoException - If an error occurred

getCount

public long getCount(com.mongodb.DBObject query)
              throws com.mongodb.MongoException
calls DBCollection.getCount(com.mongodb.DBObject, com.mongodb.DBObject) with null fields.

Parameters:
query - query to match
Returns:
The count
Throws:
com.mongodb.MongoException - If an error occurred

getCount

public long getCount(T query)
              throws com.mongodb.MongoException
calls DBCollection.getCount(com.mongodb.DBObject, com.mongodb.DBObject) with null fields.

Parameters:
query - query to match
Returns:
The count
Throws:
com.mongodb.MongoException - If an error occurred

getCount

public long getCount(com.mongodb.DBObject query,
                     com.mongodb.DBObject fields)
              throws com.mongodb.MongoException
calls DBCollection.getCount(com.mongodb.DBObject, com.mongodb.DBObject, long, long) with limit=0 and skip=0

Parameters:
query - query to match
fields - fields to return
Returns:
The count
Throws:
com.mongodb.MongoException - If an error occurred

getCount

public long getCount(T query,
                     T fields)
              throws com.mongodb.MongoException
calls DBCollection.getCount(com.mongodb.DBObject, com.mongodb.DBObject, long, long) with limit=0 and skip=0

Parameters:
query - query to match
fields - fields to return
Returns:
The count
Throws:
com.mongodb.MongoException - If an error occurred

getCount

public long getCount(com.mongodb.DBObject query,
                     com.mongodb.DBObject fields,
                     long limit,
                     long skip)
              throws com.mongodb.MongoException
Returns the number of documents in the collection that match the specified query

Parameters:
query - query to select documents to count
fields - fields to return
limit - limit the count to this value
skip - number of entries to skip
Returns:
number of documents that match query and fields
Throws:
com.mongodb.MongoException - If an error occurred

getCount

public long getCount(T query,
                     T fields,
                     long limit,
                     long skip)
              throws com.mongodb.MongoException
Returns the number of documents in the collection that match the specified query

Parameters:
query - query to select documents to count
fields - fields to return
limit - limit the count to this value
skip - number of entries to skip
Returns:
number of documents that match query and fields
Throws:
com.mongodb.MongoException - If an error occurred

rename

public JacksonDBCollection<T,K> rename(String newName)
                                throws com.mongodb.MongoException
Calls DBCollection.rename(java.lang.String, boolean) with dropTarget=false

Parameters:
newName - new collection name (not a full namespace)
Returns:
the new collection
Throws:
com.mongodb.MongoException - If an error occurred

rename

public JacksonDBCollection<T,K> rename(String newName,
                                       boolean dropTarget)
                                throws com.mongodb.MongoException
renames of this collection to newName

Parameters:
newName - new collection name (not a full namespace)
dropTarget - if a collection with the new name exists, whether or not to drop it
Returns:
the new collection
Throws:
com.mongodb.MongoException - If an error occurred

group

public com.mongodb.DBObject group(com.mongodb.DBObject key,
                                  com.mongodb.DBObject cond,
                                  com.mongodb.DBObject initial,
                                  String reduce)
                           throws com.mongodb.MongoException
calls DBCollection.group(com.mongodb.DBObject, com.mongodb.DBObject, com.mongodb.DBObject, java.lang.String, java.lang.String) with finalize=null

Parameters:
key - - { a : true }
cond - - optional condition on query
reduce - javascript reduce function
initial - initial value for first match on a key
Returns:
The results
Throws:
com.mongodb.MongoException - If an error occurred
See Also:
http://www.mongodb.org/display/DOCS/Aggregation

group

public com.mongodb.DBObject group(com.mongodb.DBObject key,
                                  com.mongodb.DBObject cond,
                                  com.mongodb.DBObject initial,
                                  String reduce,
                                  String finalize)
                           throws com.mongodb.MongoException
Applies a group operation

Parameters:
key - - { a : true }
cond - - optional condition on query
reduce - javascript reduce function
initial - initial value for first match on a key
finalize - An optional function that can operate on the result(s) of the reduce function.
Returns:
The results
Throws:
com.mongodb.MongoException - If an error occurred
See Also:
http://www.mongodb.org/display/DOCS/Aggregation

group

public com.mongodb.DBObject group(com.mongodb.GroupCommand cmd)
Applies a group operation

Parameters:
cmd - the group command
Returns:
The results
Throws:
com.mongodb.MongoException
See Also:
http://www.mongodb.org/display/DOCS/Aggregation

distinct

public List distinct(String key)
find distinct values for a key

Parameters:
key - The key
Returns:
The results

distinct

public List distinct(String key,
                     com.mongodb.DBObject query)
find distinct values for a key

Parameters:
key - The key
query - query to match
Returns:
The results

mapReduce

@Deprecated
public com.mongodb.MapReduceOutput mapReduce(String map,
                                                        String reduce,
                                                        String outputTarget,
                                                        com.mongodb.DBObject query)
                                      throws com.mongodb.MongoException
Deprecated. 

performs a map reduce operation Runs the command in REPLACE output mode (saves to named collection)

Parameters:
map - map function in javascript code
outputTarget - optional - leave null if want to use temp collection
reduce - reduce function in javascript code
query - to match
Returns:
The output
Throws:
com.mongodb.MongoException - If an error occurred

mapReduce

@Deprecated
public com.mongodb.MapReduceOutput mapReduce(String map,
                                                        String reduce,
                                                        String outputTarget,
                                                        com.mongodb.MapReduceCommand.OutputType outputType,
                                                        com.mongodb.DBObject query)
                                      throws com.mongodb.MongoException
Deprecated. 

performs a map reduce operation Specify an outputType to control job execution * INLINE - Return results inline * REPLACE - Replace the output collection with the job output * MERGE - Merge the job output with the existing contents of outputTarget * REDUCE - Reduce the job output with the existing contents of outputTarget

Parameters:
map - map function in javascript code
outputTarget - optional - leave null if want to use temp collection
outputType - set the type of job output
reduce - reduce function in javascript code
query - to match
Returns:
The output
Throws:
com.mongodb.MongoException - If an error occurred

mapReduce

@Deprecated
public com.mongodb.MapReduceOutput mapReduce(com.mongodb.MapReduceCommand command)
                                      throws com.mongodb.MongoException
Deprecated. 

performs a map reduce operation

Parameters:
command - object representing the parameters
Returns:
The results
Throws:
com.mongodb.MongoException - If an error occurred

mapReduce

@Deprecated
public com.mongodb.MapReduceOutput mapReduce(com.mongodb.DBObject command)
                                      throws com.mongodb.MongoException
Deprecated. 

performs a map reduce operation

Parameters:
command - object representing the parameters
Returns:
The output
Throws:
com.mongodb.MongoException - If an error occurred

mapReduce

public <S,L> MapReduceOutput<S,L> mapReduce(MapReduce.MapReduceCommand<S,L> command)
                               throws com.mongodb.MongoException
Performs a map reduce operation

Parameters:
command - The command to execute
Returns:
The output
Throws:
com.mongodb.MongoException - If an error occurred

getIndexInfo

public List<com.mongodb.DBObject> getIndexInfo()
Return a list of the indexes for this collection. Each object in the list is the "info document" from MongoDB

Returns:
list of index documents

dropIndex

public void dropIndex(com.mongodb.DBObject keys)
               throws com.mongodb.MongoException
Drops an index from this collection

Parameters:
keys - keys of the index
Throws:
com.mongodb.MongoException - If an error occurred

dropIndex

public void dropIndex(String name)
               throws com.mongodb.MongoException
Drops an index from this collection

Parameters:
name - name of index to drop
Throws:
com.mongodb.MongoException - If an error occurred

getStats

public com.mongodb.CommandResult getStats()
gets the collections statistics ("collstats" command)

Returns:
the stats

isCapped

public boolean isCapped()
returns whether or not this is a capped collection

Returns:
whether it is capped

getCollection

public <S,L> JacksonDBCollection<S,L> getCollection(String n,
                                                    Class<S> type,
                                                    Class<L> keyType)
Finds a collection that is prefixed with this collection's name. A typical use of this might be
    DBCollection users = mongo.getCollection( "wiki" ).getCollection( "users" );
 
Which is equivalent to
DBCollection users = mongo.getCollection( "wiki.users" );

Parameters:
n - the name of the collection to find
type - The type of the collection
Returns:
the matching collection

getName

public String getName()
Returns the name of this collection.

Returns:
the name of this collection

getFullName

public String getFullName()
Returns the full name of this collection, with the database name as a prefix.

Returns:
the name of this collection

getDB

public com.mongodb.DB getDB()
Returns the database this collection is a member of.

Returns:
this collection's database

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

setWriteConcern

public void setWriteConcern(com.mongodb.WriteConcern concern)
Set the write concern for this collection. Will be used for writes to this collection. Overrides any setting of write concern at the DB level. See the documentation for WriteConcern for more information.

Parameters:
concern - write concern to use

getWriteConcern

public com.mongodb.WriteConcern getWriteConcern()
Get the write concern for this collection.

Returns:
THe write concern

setReadPreference

public void setReadPreference(com.mongodb.ReadPreference preference)
Sets the read preference for this collection. Will be used as default for reads from this collection; overrides DB & Connection level settings. See the * documentation for ReadPreference for more information.

Parameters:
preference - Read Preference to use

getReadPreference

public com.mongodb.ReadPreference getReadPreference()
Gets the read preference

Returns:
The read preference

addOption

public void addOption(int option)
adds a default query option

Parameters:
option - The option to add

setOptions

public void setOptions(int options)
sets the default query options

Parameters:
options - The options

resetOptions

public void resetOptions()
resets the default query options


getOptions

public int getOptions()
gets the default query options

Returns:
The options

getCollectionKey

public JacksonCollectionKey getCollectionKey()
Get the type of this collection

Returns:
The type

getReferenceCollection

public <T,K> JacksonDBCollection<T,K> getReferenceCollection(String collectionName,
                                                             org.codehaus.jackson.type.JavaType type,
                                                             org.codehaus.jackson.type.JavaType keyType)
Get a collection for loading a reference of the given type

Parameters:
collectionName - The name of the collection
type - The type of the object
keyType - the type of the id
Returns:
The collection

getReferenceCollection

public <T,K> JacksonDBCollection<T,K> getReferenceCollection(JacksonCollectionKey collectionKey)
Get a collection for loading a reference of the given type

Parameters:
collectionKey - The key for the collection
Returns:
The collection

convertFromDbId

public K convertFromDbId(Object object)


Copyright © 2011-2012 VZ Netzwerke. All Rights Reserved.