/** * Returns a single object from this collection matching the query. * * @param query the query object * @return the object found, or <code>null</code> if no such object exists * @throws MongoException If an error occurred */ public T findOne(DBObject query) throws MongoException { return findOne(query, null); }
/** * Returns a single object from this collection matching the query. * * @param query the query object * @return the object found, or <code>null</code> if no such object exists * @throws MongoException If an error occurred */ public T findOne(T query) throws MongoException { return findOne(query, null); }
/** * Returns a single object from this collection matching the query. * * @param query the query object * @return the object found, or <code>null</code> if no such object exists * @throws MongoException If an error occurred */ public T findOne(DBObject query) throws MongoException { return findOne(query, null); }
/** * Returns a single object from this collection matching the query. * * @param query the query object * @return the object found, or <code>null</code> if no such object exists * @throws MongoException If an error occurred */ public T findOne(T query) throws MongoException { return findOne(query, null); }
/** * Returns a single object from this collection. * * @return the object found, or <code>null</code> if the collection is empty * @throws MongoException If an error occurred */ public T findOne() throws MongoException { return findOne(new BasicDBObject()); }
/** * Returns a single object from this collection. * * @return the object found, or <code>null</code> if the collection is empty * @throws MongoException If an error occurred */ public T findOne() throws MongoException { return findOne(new BasicDBObject()); }
/** * Returns a single object from this collection matching the query. * * @param query the query object * @param fields an object for which every non null field will be returned * @return the object found, or <code>null</code> if no such object exists */ public T findOne(T query, T fields) { return findOne(query, fields, getReadPreference()); }
/** * Returns a single object from this collection matching the query. * * @param query the query object * @param fields the fields to return * @return the object found, or <code>null</code> if no such object exists */ public T findOne(DBObject query, DBObject fields) { return findOne(query, fields, getReadPreference()); }
/** * Returns a single object from this collection matching the query. * * @param query the query object * @param fields the fields to return * @return the object found, or <code>null</code> if no such object exists */ public T findOne(DBObject query, DBObject fields) { return findOne(query, fields, getReadPreference()); }
/** * Find an object by the given id * * @param id The id * @return The object * @throws MongoException If an error occurred */ public T findOneById(K id, DBObject fields) throws MongoException { return findOne(createIdQuery(id), fields); }
/** * Returns a single object from this collection matching the query. * * @param query the query object * @param fields an object for which every non null field will be returned * @return the object found, or <code>null</code> if no such object exists */ public T findOne(T query, T fields) { return findOne(query, fields, getReadPreference()); }
/** * Find an object by the given id * * @param id The id * @return The object * @throws MongoException If an error occurred */ public T findOneById(K id, DBObject fields) throws MongoException { return findOne(createIdQuery(id), fields); }