Mapping a Collection without using DBRef (Spring Data MongoDB) -
i've been reading lot use of dbref collection mapping in spring data/mongodb discouraged. so, how can implement mapping stores array of objectid taken objects inside students collection?
assuming have following pojo model:
@document (collection = "courses") public class course { @id private string id; private string name; private list<student> students = new linkedlist<student>(); //.. constructors, getters , setters .. } public interface courserepository extends mongorepository<course, string> { }
the result should this:
courses { _id : objectid("foo"), _class: "model.course", name: "mongodb dummies", students: [ objectid("foo2"), objectid("foo3"), ... ] }
instead of this:
courses { _id : objectid("foo"), _class: "model.course", name: "mongodb dummies", students: [ dbref("student", objectid("foo2")), dbref("student", objectid("foo3")) ] }
thanks!
you might wanna try obvious , change students
list<objectid>
. ;)
Comments
Post a Comment