@IdPrefix (and other similar) annotations not working at all



I saw a sample usage of @IdPrefix (and other similar) here. I am trying to store a document in the DB but somehow the key is still without prefix (or suffixes that i use!)

Unlike in the above link, I am using ReactiveCouchbaseRepository to save the doc (rather than template). The following is the relevant code sample.

the model class

@EqualsAndHashCode(of = {"id"})
public final class User {

private static final String DOC_TYPE = "user";

@GeneratedValue(strategy = GenerationStrategy.USE_ATTRIBUTES, delimiter = "::")
private final String id;

private String prefix = DOC_TYPE;


the test class

public class UserRepositoryTest {

private static final User TEST_USER = User.createNew(Status.NEW, asList(new Profile(ProfileName.DOCTOR, Status.NEW)));

UserApplication.UserRepository userRepository;

public void shouldSaveUser() throws ParseException {
    final User user = User.createNew(/*...populate values, including id.../*);


Here, post this method is executed, the doc stored does not have the prefix in the doc stored in the db. Any help would be appreciated. Thanks in advance.


@nilesh_ca, did this work for you ? I am also facing same issue . Could you please help me on this, if this has worked for you ?


Hi @lokendra1985rawat, which version of SDC are you using? Is there a public getter method for the field?


Hi @subhashni, I am using couchbase 6.0 enterprise version and is integrated with springboot 2.0, so i guess it would be latest version.


Here is an example, if the field is going to be still a part of the document, use @IdAttribute, and it is required that the id field is not set, if it is set by code, then that will take precedence,

public class User {

	@Id @GeneratedValue(strategy = USE_ATTRIBUTES, delimiter = "::")
	private String id;

	@IdAttribute(order = 0)
	private String firstName;

	@IdAttribute(order = 1)
	private String lastName;

	public String getId() {
		return this.id;

	public void setId(String id) {
		this.id = id;

	public String getFirstName() {
		return this.firstName;

	public void setFirstName(String firstName) {
		this.firstName = firstName;

	public String getLastName() {
		return this.lastName;

	public void setLastName(String lastName) {
		this.lastName = lastName;

User user = new User();

the result document will have id Alice::Smith