I would like to know how to generate a unique id with prefix e.g. user::524525 with Couchbase SDK.
When I started with Couchbase using the Couchbase JavaSDK guide, I noticed that in all the examples the id looks like TYPE::ID e.g user::king_arthur. This is also recommended to avoid conflicting ids for different documents. As I was reading the documentation from Spring Data Couchbase I thought the way to do it would be
import org.springframework.data.couchbase.core.mapping.id.GeneratedValue;
import org.springframework.data.couchbase.core.mapping.id.GenerationStrategy;
import org.springframework.data.couchbase.core.mapping.id.IdPrefix;
import com.couchbase.client.java.repository.annotation.Id;
...
@Data
public class UserĀ {
@IdPrefix
private String prefix = "user";
@Id @GeneratedValue(delimiter = "::", strategy = GenerationStrategy.USE_ATTRIBUTES)
private String id;
}
but when I test this and check in the db, the ID is just "user".
Am I missing something? Is it a bug? I would appreciate any suggestions.