Package dev.morphia

Class InsertOneOptions

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

    public class InsertOneOptions
    extends Object
    implements dev.morphia.internal.WriteConfigurable<InsertOneOptions>, dev.morphia.internal.CollectionConfigurable<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

        @MorphiaInternal
        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

      • bypassDocumentValidation

        public InsertOneOptions bypassDocumentValidation​(@Nullable
                                                         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
      • collection

        public InsertOneOptions collection​(@Nullable
                                           String collection)
        Specifies an alternate collection to use rather than the mapped collection.
        Specified by:
        collection in interface dev.morphia.internal.CollectionConfigurable<InsertOneOptions>
        Parameters:
        collection - the name of the collection to use
        Returns:
        the options
      • collection

        @MorphiaInternal
        public String collection()
        Description copied from interface: dev.morphia.internal.CollectionConfigurable
        Returns the alternate collection to use for the operation. Might return null.
        Specified by:
        collection in interface dev.morphia.internal.CollectionConfigurable<InsertOneOptions>
        Returns:
        the collection
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getBypassDocumentValidation

        @Nullable
        @Deprecated(forRemoval=true,
                    since="2.3")
        public Boolean getBypassDocumentValidation()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Gets the the bypass document level validation flag
        Returns:
        the bypass document level validation flag
      • bypassDocumentValidation

        @Nullable
        @MorphiaInternal
        public Boolean bypassDocumentValidation()
        Returns:
        the bypass document level validation flag
        See Also:
        InsertOneOptions.getBypassDocumentValidation()
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • getOptions

        @Deprecated(forRemoval=true,
                    since="2.3")
        public InsertOneOptions getOptions()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Returns:
        the driver version of the options
      • options

        @MorphiaInternal
        public InsertOneOptions options()
        Returns:
        the driver version of the options
        Developer note.
        This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
      • unsetMissing

        @Deprecated(forRemoval=true,
                    since="2.3")
        public boolean unsetMissing()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Applies the rules for storing null/empty values for fields not present in the object to be merged.
        Returns:
        this true if the rules for storing null/empty values should be applied
        Since:
        2.2
      • unsetMissing

        public InsertOneOptions unsetMissing​(boolean unset)
        Applies the rules for storing null/empty values for fields no present in the object to be merged.
        Parameters:
        unset - true if the rules should be applied
        Returns:
        this
        Since:
        2.2
      • writeConcern

        public InsertOneOptions writeConcern​(@Nullable
                                             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

        @Nullable
        public 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.