Overview
In this guide, you can learn about how the Java driver configures CRUD
operations for MongoDatabase and MongoCollection instances.
Read preferences, read concerns, and write concerns control how the driver routes read operations and waits for acknowledgment for read and write operations when connected to a MongoDB replica set. Read preferences and read concerns apply to all read operations; write concerns apply to all write operations.
For more information, see the server documentation on read preferences, read concerns, and write concerns.
By default, MongoDatabase and MongoCollection instances inherit their preferences
and concerns from the MongoClient that accesses them. See the
Configure Client-level CRUD Settings page for
more information. However, you can apply custom settings to your individual databases and
collections by using the following methods:
Tip
The withReadConcern(), withReadPreference(), and
withWriteConcern methods create a new instance of a
MongoDatabase or MongoCollection with the desired preference
or concern. The MongoDatabase or MongoCollection upon which
the method is called retains its original preference and concern
settings.