Bug report

it's Class

import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.FieldType;
import org.springframework.data.mongodb.core.mapping.MongoId;

@Document
public class Member {

  @MongoId(targetType = FieldType.STRING)
  private String _id;

  private String name;

  private Integer gender;

  private String phoneNum;

  private String mailbox;

  private Boolean enabled;

  private String tenantId;
  private String creatorId;
  private Long create;
  private Long update;
}

I use this method:

package org.springframework.data.mongodb.core;
    /**
     * Insert the object into the specified collection.
     * <br />
     * The object is converted to the MongoDB native representation using an instance of {@see MongoConverter}. Unless
     * configured otherwise, an instance of {@link MappingMongoConverter} will be used.
     * <br />
     * Insert is used to initially store the object into the database. To update an existing object use the save method.
     * <br />
     * The {@code objectToSave} must not be collection-like.
     *
     * @param objectToSave the object to store in the collection. Must not be {@literal null}.
     * @param collectionName name of the collection to store the object in. Must not be {@literal null}.
     * @return the inserted object.
     * @throws IllegalArgumentException in case the {@code objectToSave} is collection-like.
     */
<T> Mono<T> insert(T objectToSave, String collectionName);

T :

{
    "_id": "14187o",
    "name": "gaoqiao",
    "phoneNum": "+86-150******62",
    "enabled": true,
    "tenantId": "402",
    "creatorId": "14187o",
    "create": 1665804058211,
    "update": 1665804058211
}

BUT DB'result is:

{
    "_id" : "634a295b524e18188627d6ce",
    "name" : "gaoqiao",
    "phoneNum" : "+86-150******62",
    "enabled" : true,
    "tenantId" : "402",
    "creatorId" : "14187o",
    "create" : 1665804058211,
    "update" : 1665804058211
}

The problem is only encountered in this version

build.gradle

plugins { id 'org.springframework.boot' version '2.7.4' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' }

2.7.1 2.7.2 2.7.3 is ok

Comment From: wilkinsona

Duplicates #32635 and https://github.com/spring-projects/spring-data-mongodb/issues/4184.