Friday, 30 August 2013

Fetching Bidirectional DbRef relations Spring Data + MongoDB

Fetching Bidirectional DbRef relations Spring Data + MongoDB

I am new to MongoDB. I am preparing an example for learning. It looks like
when working with bi-directional relationship with Spring Data & DBRef, it
gets into end-less cycle and keeps reading the association again and
again.
The domain class looks like class Category{ private String name; private
Category parentCategory; private Set childCategories; // getter & setters
}
I wonder if it is the rare scenario to have this sort of bi-directional
relationship(quite commong in ORMs though), couldn't get any help on this.
One option could be writing custom converter and ignoring anyone side of
relation, but that will turn my in-memory object into an inconsistent
state.
Please share ideas on this or some best practices on handling such scenarios.
Thanks, Vishal Shukla

No comments:

Post a Comment