Java SDK @Id field cannot be null or empty

I have a problem when I want to add document using Java SDK, I get the following error: “The @Id field cannot be null or empty.” I don’t understand why because my Document Entity class inherits ID field with @Id annotation from super class…

Is this using Spring Data or the like? Maybe you can paste or link to a short code sample that demonstrates the problem.

The error appears to come from the KeyValueLocator class and is accurate. If it’s null/empty, somehting either is failing to set it or clearing it. You might examine from that exception with a debugger to figure out what’s going on.

I have abstract class which contains all common properties in my model:

import com.fasterxml.jackson.annotation.JsonProperty;

public abstract class AbstractEntity implements Entity {

private String id;

private String rev;

private String ownerId;

private DocumentType type;


And multiple classes that extend AbstractEntity, like BrandEntity for example:

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class BrandEntity extends AbstractEntity implements Brand {

private String name;
private String description;

public String getName() {
    return name;

public void setName(String name) { = name;

public String getDescription() {
    return description;

public void setDescription(String description) {
    this.description = description;


But when I try to save entity for example:

EntityDocument(Brand)* entityDoc = EntityDocument.create(entity);
EntityDocument(Brand)* newDocument = bucket.repository().insert(entityDoc);
*<> are not showing text inside

ID is printed and the exception is thrown:

RepositoryMappingException “The @Id field cannot be null or empty.”

Which is not true because I checked the value in debugger and printed it in the console.

Ah, it’s using the repository, which as you probably know from the javadoc is marked volatile/experimental. That looks like a bug to me.

I’ve filed JCBC-1158 to investigate. You can track it there.