CrudRepository保存方法不执行更新

时间:2018-07-06 07:23:08

标签: mongodb spring-data

我正在尝试使用CrudRepository save()方法进行升级

testRepository.save(myObject);

事实证明,更新未发生,但引发了以下异常:

com.mongodb.DuplicateKeyException: Write failed with error code 11000 and error message 'E11000 duplicate key error collection: db.collection index: _id_ dup key: { : ObjectId('5b3bc303a162ef3e28fc861e') }'
at com.mongodb.operation.BaseWriteOperation.convertBulkWriteException(BaseWriteOperation.java:243) ~[mongo-java-driver-3.4.1.jar:na]
at com.mongodb.operation.BaseWriteOperation.access$300(BaseWriteOperation.java:60) ~[mongo-java-driver-3.4.1.jar:na]
at com.mongodb.operation.BaseWriteOperation$1.call(BaseWriteOperation.java:144) ~[mongo-java-driver-3.4.1.jar:na]

我想念什么吗?我正在使用MongoDB 3.6.3和mongo-java-driver-3.4.1

0 个答案:

没有答案