Package com.mongodb
Class InsertOptions
- java.lang.Object
 - 
- com.mongodb.InsertOptions
 
 
- 
public final class InsertOptions extends java.lang.ObjectOptions related to insertion of documents into MongoDB. The setter methods returnthisso that a chaining style can be used.- Since:
 - 2.13
 
 
- 
- 
Constructor Summary
Constructors Constructor Description InsertOptions() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InsertOptionsbypassDocumentValidation(java.lang.Boolean bypassDocumentValidation)Sets whether to bypass document validation.InsertOptionscontinueOnError(boolean continueOnError)Set whether documents will continue to be inserted after a failure to insert one.InsertOptionsdbEncoder(DBEncoder dbEncoder)Set the encoder to use for the documents.java.lang.BooleangetBypassDocumentValidation()Gets whether to bypass document validation, or null if unspecified.DBEncodergetDbEncoder()The encoder to use for the documents.WriteConcerngetWriteConcern()The write concern to use for the insertion.booleanisContinueOnError()Whether documents will continue to be inserted after a failure to insert one (most commonly due to a duplicate key error).InsertOptionswriteConcern(WriteConcern writeConcern)Set the write concern to use for the insert. 
 - 
 
- 
- 
Method Detail
- 
writeConcern
public InsertOptions writeConcern(@Nullable WriteConcern writeConcern)
Set the write concern to use for the insert.- Parameters:
 writeConcern- the write concern- Returns:
 - this
 
 
- 
continueOnError
public InsertOptions continueOnError(boolean continueOnError)
Set whether documents will continue to be inserted after a failure to insert one.- Parameters:
 continueOnError- whether to continue on error- Returns:
 - this
 
 
- 
dbEncoder
public InsertOptions dbEncoder(@Nullable DBEncoder dbEncoder)
Set the encoder to use for the documents.- Parameters:
 dbEncoder- the encoder- Returns:
 - this
 
 
- 
getWriteConcern
@Nullable public WriteConcern getWriteConcern()
The write concern to use for the insertion. By default the write concern configured for the DBCollection instance will be used.- Returns:
 - the write concern, or null if the default will be used.
 
 
- 
isContinueOnError
public boolean isContinueOnError()
Whether documents will continue to be inserted after a failure to insert one (most commonly due to a duplicate key error). Note that this only is relevant for multi-document inserts. The default value is false.- Returns:
 - whether insertion will continue on error.
 
 
- 
getDbEncoder
@Nullable public DBEncoder getDbEncoder()
The encoder to use for the documents. By default the codec configured for the DBCollection instance will be used.- Returns:
 - the encoder, or null if the default will be used
 
 
- 
getBypassDocumentValidation
@Nullable public java.lang.Boolean getBypassDocumentValidation()
Gets whether to bypass document validation, or null if unspecified. The default is null.- Returns:
 - whether to bypass document validation, or null if unspecified.
 - Since:
 - 2.14
 
 
- 
bypassDocumentValidation
public InsertOptions bypassDocumentValidation(@Nullable java.lang.Boolean bypassDocumentValidation)
Sets whether to bypass document validation.- Parameters:
 bypassDocumentValidation- whether to bypass document validation, or null if unspecified- Returns:
 - this
 - Since:
 - 2.14
 
 
 - 
 
 -