"Upsert document with version value failed: null; nested exception is com.couchbase.client.java.error.DocumentAlreadyExistsException


#1

Hello everyone,

I have an issue when updating a document in couchbase with error:
"Upsert document with version value failed: null; nested exception is com.couchbase.client.java.error.DocumentAlreadyExistsException

My classe is verry simple, contains

@Document
public abstract class BaseEntity {

@Id
private String id;

@Field
private String type;

@Field
private String primaryKey;

  @Version long version

// getter + setter

MyRepository extends CouchbasePagingAndSortingRepository

Th Id is calculated from other fields,
here is the principal librairies used in my project:

spring-boot-starter-data-couchbase : 2.0.5-RELEASE
spring-data-couchbase: 3.0.10.RELEASE
java-client: 2.5.9

Any help please ?


#2

Hi @karimm.khalid,

Is your application logging this “Upsert document with version value failed:”?, The version field would be automatically populated when the operation is successful, does a document with the same id already exist on the server?


#3

Hi @subhashni

Thanks for replay, I have resolve this issue.
The problem was the version is never stored with the document,( saved correctly in couchbase) but when I retried the same document by invoking a findById method (spring data) I can see the version (random long value), during the update (with mapstruct) I didn’t make a merge to set up the same version, and a new version was created for the same document (old version ixist), that’s why I have this exception: DocumentAlreadyExistsException

Thanks again