I want to reference nested object exist in another Collection object, in my Event object so that when i get Event of User than Venue of Event shall retrieve with it, i am new in mongodb and spring can any one help to do this.
class User{
private String name;
private Venue venue;
//Getter and Setter
}
class Event {
@DBRef
private Venue venue;
//Getter and Setter
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With