I am unable to perform update operation. Using spring boot with mongodb 3.4. On trying to save I am receiving the following kind of error :
WriteError{code=11000, message='E11000 duplicate key error collection
My domain class is extending another base domain class. My current findings are that the base domain class contains "private Long version" annotated with @Version. My guess is this is the field that's causing the issue. Things I have tried so far:
- On initialising "private Long version = 0L;" my document updates just once, further updates gives the below error :
Something went wrong in service layer while updating the Employee.Cannot save entity 119794669940 with version 1 to collection Employee. Has it been modified meanwhile?
- On removing @Version the data updates just fine. (not a solution because version is required)
- Looked at E11000 duplicate key error when doing PUT for modifiable resource with Spring Data Rest and tried by using @JsonIgnore on the version field. It too is throwing the same Duplicate key error :
WriteError{code=11000, message='E11000 duplicate key error collection.
Some additional info:
- I am not sending version in put body in any of the above cases I have tried so far(sending them with version key is giving the same error.
Anyone has any idea what's going on or how to proceed further?