public WriteResult insert(final List<? extends DBObject> documents, final InsertOptions insertOptions) {
        WriteConcern writeConcern = insertOptions.getWriteConcern() != null ? insertOptions.getWriteConcern() : getWriteConcern();
        Encoder<DBObject> encoder = toEncoder(insertOptions.getDbEncoder());

        List<InsertRequest> insertRequestList = new ArrayList<InsertRequest>(documents.size());
        for (DBObject cur : documents) {
            if (cur.get(ID_FIELD_NAME) == null) {
                cur.put(ID_FIELD_NAME, new ObjectId());
            }
            insertRequestList.add(new InsertRequest(new BsonDocumentWrapper<DBObject>(cur, encoder)));
        }
        return insert(insertRequestList, writeConcern, insertOptions.isContinueOnError(), insertOptions.getBypassDocumentValidation());
    }
public WriteResult insert(final List<? extends DBObject> documents, final InsertOptions insertOptions) {
        WriteConcern writeConcern = insertOptions.getWriteConcern() != null ? insertOptions.getWriteConcern() : getWriteConcern();
        Encoder<DBObject> encoder = toEncoder(insertOptions.getDbEncoder());

        List<InsertRequest> insertRequestList = new ArrayList<InsertRequest>(documents.size());
        for (DBObject cur : documents) {
            if (cur.get(ID_FIELD_NAME) == null) {
                cur.put(ID_FIELD_NAME, new ObjectId());
            }
            insertRequestList.add(new InsertRequest(new BsonDocumentWrapper<DBObject>(cur, encoder)));
        }
        return insert(insertRequestList, writeConcern, insertOptions.isContinueOnError(), insertOptions.getBypassDocumentValidation());
    }
public WriteResult insert ( final List < ? extends DBObject > documents , final InsertOptions insertOptions ) { WriteConcern writeConcern = insertOptions . getWriteConcern ( ) != null ? insertOptions . getWriteConcern ( ) : getWriteConcern ( ) ; Encoder < DBObject > encoder = toEncoder ( insertOptions . getDbEncoder ( ) ) ; List < InsertRequest > insertRequestList = new ArrayList < InsertRequest > ( documents . size ( ) ) ; for ( DBObject cur : documents ) { if ( cur . get ( ID_FIELD_NAME ) == null ) { cur . put ( ID_FIELD_NAME , new ObjectId ( ) ) ; } insertRequestList . add ( new InsertRequest ( new BsonDocumentWrapper < DBObject > ( cur , encoder ) ) ) ; } return insert ( insertRequestList , writeConcern , insertOptions . isContinueOnError ( ) , insertOptions . getBypassDocumentValidation ( ) ) ; }
<p>Insert documents into a collection. If the collection does not exists on the server, then it will be created. If the new document
does not contain an '_id' field, it will be added.</p>

<p>If the value of the continueOnError property of the given {@code InsertOptions} is true,
that value will override the value of the continueOnError property of the given {@code WriteConcern}. Otherwise,
the value of the continueOnError property of the given {@code WriteConcern} will take effect. </p>

@param documents     a list of {@code DBObject}'s to be inserted
@param insertOptions the options to use for the insert
@return the result of the operation
@throws com.mongodb.DuplicateKeyException if the write failed to a duplicate unique key
@throws com.mongodb.WriteConcernException if the write failed due some other failure specific to the insert command
@throws MongoException if the operation failed for some other reason
@mongodb.driver.manual tutorial/insert-documents/ Insert Documents
<p > Insert documents into a collection . If the collection does not exists on the server then it will be created . If the new document does not contain an _id field it will be added . < / p >