Wednesday, 20 November 2019
Spring Boot Mongo - E11000 Duplicate Key after added @version
i have to add @version because i manually create _id.
But i got "E11000 Duplicate Key" error after that.
the reason is that, the code working ok when i create a new record, but it will throw above error when i was trying to update existing data. because existing data doesn't have Version.
As one of the guys mentioned in below link (actually the best answer doesn't help)
if you have @version and auditing switched on , and if you are trying to update a document which doesn't have version or version is null, then you will have above error.
the error info doesn't help!!
update all your existing data and give a initial version: