Sagarika
Sagarika

Reputation: 41

Spring data commons 2.7.3 doesn't update when using save()

I have recently upgraded my project to java 17 and spring boot 2.7.4 and spring cloud 2021.0.4. I am using mavenBom for spring cloud dependency management. It has brought in spring-data-commons-2.7.3.

With the upgrade, the CRUD repository's save() doesn't seem to be updating the existing objects. I am getting a duplicate key exception. (org.springframework.dao.DuplicateKeyException: Document with the given id already exists). I have already tried enabling transaction management, but to no avail.

Could you please help.

Upvotes: 0

Views: 312

Answers (1)

Sagarika
Sagarika

Reputation: 41

auto-upsert is not supported by spring-data-couchbase v 4.4.3.

If you want to use upsert() on an entiy class that has an @Version property, you'll need to explicitly use template.upsertById() or introduce your own repository.upsert() method. Or override the repository.save() method.

Upvotes: 2

Related Questions