[英]MongoDB One-to-Many and Many-to-One relations in Spring Boot Project
請問如何在 mongoDB 中添加關系,因為我剛開始使用它。 例如Comment id 是一個外鍵:
@Document
class Comment {
@Id
private String id;
private String text;
private String author;
// constructors, getters and setters are ommited
}
@Document
class Article {
@Id
private String id;
@DBRef(lazy = true)
@CascadeSave
private List<Comment> comments;
private String title;
private String text;
// constructors, getters and setters are ommited
}
JPA 注釋@OneToMany 和@ManyToMany 的等效項是@DBRef
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.