Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report : version 2.7.4 Mongodb Document _id #32741

Closed
Demo-80 opened this issue Oct 15, 2022 · 1 comment
Closed

Bug report : version 2.7.4 Mongodb Document _id #32741

Demo-80 opened this issue Oct 15, 2022 · 1 comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue

Comments

@Demo-80
Copy link

Demo-80 commented Oct 15, 2022

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 15, 2022
@wilkinsona
Copy link
Member

Duplicates #32635 and spring-projects/spring-data-mongodb#4184.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2022
@wilkinsona wilkinsona added status: duplicate A duplicate of another issue for: external-project For an external project and not something we can fix and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants