'How to avoid incrementing version field with mongo document if there were no changes?
Assuming the following method that just fetch the data from the MongoDB and then save it immediately, without any changes:
@Transactional
public void doNothing() {
MyDocument doc = repository.findById(1L).orElse(null);
repository.save(doc);
}
MyDocument contains a field with the @Version annotation.After calling the previous method, I have the version incremented.
Is there any way to stop doing that?
I'm asking this because, e.g., in spring-data-jpa the behaviour is different (because of JPA-provider's dirty check mechanism).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
