The upsert method of mongodb inserts data id is null?

spring integration MongoDB, wants to add and modify functions in a method. After using mongoTemplate.upsert, it is found that the id value of inserting new data is null, but there is id in insert insertion. Why? How to solve? I am not very familiar with MongoDB just now.

Jan.13,2022

not very familiar with Spring either. After checking the document, the upsert method returns com.mongodb.client.result.UpdateResult . This object has getUpsertedId :

If the replace resulted in an inserted document, gets the _ id of the inserted document, otherwise null.

this should be the ID you want

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7bb2d5-1f208.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7bb2d5-1f208.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?