@@ -315,21 +315,9 @@ public final DBCursor find( DBObject query , DBObject fields , int numToSkip , i
315
315
*/
316
316
public final DBObject findOne ( Object obj )
317
317
throws MongoException {
318
- return findOne (obj , null , _readPref );
318
+ return findOne (obj , null );
319
319
}
320
320
321
- /**
322
- * Finds an object by its id.
323
- * This compares the passed in value to the _id field of the document
324
- *
325
- * @param obj any valid object
326
- * @return the object, if found, otherwise <code>null</code>
327
- * @throws MongoException
328
- */
329
- public final DBObject findOne ( Object obj , ReadPreference readPref )
330
- throws MongoException {
331
- return findOne (obj , null , readPref );
332
- }
333
321
334
322
/**
335
323
* Finds an object by its id.
@@ -341,20 +329,7 @@ public final DBObject findOne( Object obj , ReadPreference readPref )
341
329
* @dochub find
342
330
*/
343
331
public final DBObject findOne ( Object obj , DBObject fields ) {
344
- return findOne ( obj , fields , _readPref );
345
- }
346
-
347
- /**
348
- * Finds an object by its id.
349
- * This compares the passed in value to the _id field of the document
350
- *
351
- * @param obj any valid object
352
- * @param fields fields to return
353
- * @return the object, if found, otherwise <code>null</code>
354
- * @dochub find
355
- */
356
- public final DBObject findOne ( Object obj , DBObject fields , ReadPreference readPref ) {
357
- Iterator <DBObject > iterator = __find (new BasicDBObject ("_id" , obj ), fields , 0 , -1 , 0 , getOptions (), readPref , _decoderFactory .create () );
332
+ Iterator <DBObject > iterator = __find (new BasicDBObject ("_id" , obj ), fields , 0 , -1 , 0 , getOptions (), _readPref , _decoderFactory .create () );
358
333
return (iterator != null ? iterator .next () : null );
359
334
}
360
335
@@ -590,18 +565,7 @@ public void setHintFields( List<DBObject> lst ){
590
565
* @dochub find
591
566
*/
592
567
public final DBCursor find ( DBObject ref ){
593
- return find ( ref , _readPref );
594
- }
595
-
596
- /**
597
- * Queries for an object in this collection.
598
- * @param ref object for which to search
599
- * @param preference Read Preference for this write
600
- * @return an iterator over the results
601
- * @dochub find
602
- */
603
- public final DBCursor find ( DBObject ref , ReadPreference preference ){
604
- return new DBCursor ( this , ref , null , preference );
568
+ return new DBCursor ( this , ref , null , _readPref );
605
569
}
606
570
607
571
/**
@@ -628,52 +592,17 @@ public final DBCursor find( DBObject ref, ReadPreference preference ){
628
592
* @dochub find
629
593
*/
630
594
public final DBCursor find ( DBObject ref , DBObject keys ){
631
- return find ( ref , keys , _readPref );
595
+ return new DBCursor ( this , ref , keys , _readPref );
632
596
}
633
597
634
- /**
635
- * Queries for an object in this collection.
636
- *
637
- * <p>
638
- * An empty DBObject will match every document in the collection.
639
- * Regardless of fields specified, the _id fields are always returned.
640
- * </p>
641
- * <p>
642
- * An example that returns the "x" and "_id" fields for every document
643
- * in the collection that has an "x" field:
644
- * </p>
645
- * <blockquote><pre>
646
- * BasicDBObject keys = new BasicDBObject();
647
- * keys.put("x", 1);
648
- *
649
- * DBCursor cursor = collection.find(new BasicDBObject(), keys);
650
- * </pre></blockquote>
651
- *
652
- * @param ref object for which to search
653
- * @param keys fields to return
654
- * @return a cursor to iterate over results
655
- * @dochub find
656
- */
657
- public final DBCursor find ( DBObject ref , DBObject keys , ReadPreference readPref ){
658
- return new DBCursor ( this , ref , keys , readPref );
659
- }
660
598
661
599
/**
662
600
* Queries for all objects in this collection.
663
601
* @return a cursor which will iterate over every object
664
602
* @dochub find
665
603
*/
666
604
public final DBCursor find (){
667
- return find ( _readPref );
668
- }
669
-
670
- /**
671
- * Queries for all objects in this collection.
672
- * @return a cursor which will iterate over every object
673
- * @dochub find
674
- */
675
- public final DBCursor find ( ReadPreference readPref ){
676
- return new DBCursor ( this , new BasicDBObject (), null , readPref );
605
+ return new DBCursor ( this , null , null , _readPref );
677
606
}
678
607
679
608
/**
@@ -686,16 +615,6 @@ public final DBObject findOne()
686
615
return findOne ( new BasicDBObject () );
687
616
}
688
617
689
- /**
690
- * Returns a single object from this collection.
691
- * @return the object found, or <code>null</code> if the collection is empty
692
- * @throws MongoException
693
- */
694
- public final DBObject findOne ( ReadPreference readPref )
695
- throws MongoException {
696
- return findOne ( new BasicDBObject (), readPref );
697
- }
698
-
699
618
/**
700
619
* Returns a single object from this collection matching the query.
701
620
* @param o the query object
@@ -707,17 +626,6 @@ public final DBObject findOne( DBObject o )
707
626
return findOne ( o , null , _readPref );
708
627
}
709
628
710
- /**
711
- * Returns a single object from this collection matching the query.
712
- * @param o the query object
713
- * @return the object found, or <code>null</code> if no such object exists
714
- * @throws MongoException
715
- */
716
- public final DBObject findOne ( DBObject o , ReadPreference readPref )
717
- throws MongoException {
718
- return findOne ( o , null , readPref );
719
- }
720
-
721
629
/**
722
630
* Returns a single object from this collection matching the query.
723
631
* @param o the query object
0 commit comments