spring-boot-data-couchbase
The different exceptions while using spring-boot-data-couchbase and how I swam through
(1) An ID property is needed, but not found/could not be generated on this entity.
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [void]: Factory method ‘insertData’ threw exception; nested exception is org.springframework.data.mapping.MappingException: An ID property is needed, but not found/could not be generated on this entity.
I had javax.validation annotation @NotNull for id field
public class Building { @NotNull @Id @GeneratedValue private String id;
Removed the @NotNull annotation to resolve the issue.
(2) The Document ID must not be null or empty.
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [void]: Factory method ‘insertData’ threw exception; nested exception is java.lang.IllegalArgumentException: The Document ID must not be null or empty.
Used the following strategy for ID Generation to resolve the issue.
public class Building {
@Id
@GeneratedValue(strategy = UNIQUE)
private String id;
import org.springframework.data.annotation.Id; import org.springframework.data.couchbase.core.mapping.Document; import org.springframework.data.couchbase.core.mapping.id.GeneratedValue; import static org.springframework.data.couchbase.core.mapping.id.GenerationStrategy.UNIQUE;
Hope this helps
No comments:
Post a Comment