I have a springBoot 2.1.9.RELEASE application that uses Spring Data for Couchbase
I have this object
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Hostel<T> {
@NotNull
@JsonProperty("_location")
private T location;
}
and this other one
@Document
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(of = { "id" })
@Builder
public class HTMDoc {
@Id
private String id;
@NotNull
@Field
private Hostel hostel;
}
on the service
public HTMDoc create(@Valid HTMDoc doc) {
return repository.save(doc);
}
on the test
service.create(new HTMDoc());
but when I save I got this error instead of the validation NotNull in the hostel field
org.springframework.data.mapping.MappingException: An ID property is needed, but not found/could not be generated on this entity.