Reputation: 337
please how can I add relations in a mongoDB cause I just start using it. For example Comment id is a foreign key:
@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
}
Upvotes: 1
Views: 7748
Reputation: 337
The equivalence of the JPA annotation @OneToMany and @ManyToMany is @DBRef
Upvotes: 3