Package dev.morphia

Class InsertOneOptions

  • All Implemented Interfaces:
    dev.morphia.internal.SessionConfigurable<InsertOneOptions>, dev.morphia.internal.WriteConfigurable<InsertOneOptions>

    public class InsertOneOptions
    extends Object
    implements dev.morphia.internal.SessionConfigurable<InsertOneOptions>, dev.morphia.internal.WriteConfigurable<InsertOneOptions>
    Options related to insertion of documents into MongoDB. The setter methods return this so that a chaining style can be used.
    Since:
    1.3
    • Constructor Detail

      • InsertOneOptions

        public InsertOneOptions()
        Creates a new options wrapper
      • InsertOneOptions

        public InsertOneOptions​(InsertOneOptions that)
        Parameters:
        that - the options to copy
        Since:
        2.0
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
    • Method Detail

      • clientSession

        public InsertOneOptions clientSession​(com.mongodb.client.ClientSession clientSession)
        Description copied from interface: dev.morphia.internal.SessionConfigurable
        Set the client session to use for the insert.
        Specified by:
        clientSession in interface dev.morphia.internal.SessionConfigurable<InsertOneOptions>
        Parameters:
        clientSession - the client session
        Returns:
        this
      • clientSession

        public com.mongodb.client.ClientSession clientSession()
        Description copied from interface: dev.morphia.internal.SessionConfigurable
        The client session to use for the insertion.
        Specified by:
        clientSession in interface dev.morphia.internal.SessionConfigurable<InsertOneOptions>
        Returns:
        the client session
      • writeConcern

        public InsertOneOptions writeConcern​(com.mongodb.WriteConcern writeConcern)
        Set the write concern to use for the insert.
        Specified by:
        writeConcern in interface dev.morphia.internal.WriteConfigurable<InsertOneOptions>
        Parameters:
        writeConcern - the write concern
        Returns:
        this
      • writeConcern

        public com.mongodb.WriteConcern writeConcern()
        The write concern to use for the insertion. By default the write concern configured for the MongoCollection instance will be used.
        Specified by:
        writeConcern in interface dev.morphia.internal.WriteConfigurable<InsertOneOptions>
        Returns:
        the write concern, or null if the default will be used.
      • getBypassDocumentValidation

        public Boolean getBypassDocumentValidation()
        Gets the the bypass document level validation flag
        Returns:
        the bypass document level validation flag
      • bypassDocumentValidation

        public InsertOneOptions bypassDocumentValidation​(Boolean bypassDocumentValidation)
        Sets whether to bypass document validation.
        Parameters:
        bypassDocumentValidation - whether to bypass document validation, or null if unspecified
        Returns:
        this
        Since server release
        3.2
      • getOptions

        public com.mongodb.client.model.InsertOneOptions getOptions()
        Returns:
        the driver version of the options