How to reference nested object into other collection Mongodb How to reference nested object into other collection Mongodb mongodb mongodb

How to reference nested object into other collection Mongodb


If each User has one Venue, you can reference User instead of Venue in Event. If a User may have more than one Venue, you better make Venues a seperate collection and reference both in User and Event.


Try this.

class Venue{    //Getter and Setter }class User{    private String name;    @DBRef    private Venue venue;    //Getter and Setter }class Event {    @DBRef    private Venue venue;    //Getter and Setter }