I have a collection of User objects, that have a collection of friends, that are... User objects. I want to map that in Spring Boot, so I made a Model class, a Service, a Controller, you name it...
Here is my model class :
@Document(collection = "users")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
@Id
private ObjectId id;
private String username;
private String date_of_birth;
@DBRef
private List<User> friends;
}
- This is circular referencing. Is that a no-no ? This is my first time using NoSQL. I wouldn't do this in SQL, but I thought you could do that kind of things in NoSQL ?... If not, how would you go about this in a NoSQL database ?
- If the circular referencing in itself is not the problem, what could possibly be the cause of this error I get when requesting the API :
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.bson.types.ObjectId] to type [com.chlac.friendzz.User]
The documentation uses the @DBRef this way, without adding any kind of custom converter. What could be the cause of this error ?