1

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
    }
Joundill
  • 6,828
  • 12
  • 36
  • 50
Kindth
  • 337
  • 1
  • 8
  • 30

1 Answers1

3

The equivalence of the JPA annotation @OneToMany and @ManyToMany is @DBRef

Kindth
  • 337
  • 1
  • 8
  • 30