开发者

Morphia update recursive document

I currently have a model that has an array of objects of the same type as a field. These objects in the array can have their own children of the same type, and so on.

I'm trying to, using Morphia, update an object N levels down in the hierarchy. What I do is keep a reference to the ID of the "开发者_StackOverflowroot" document. (The one that is actually queryable in Mongo) I then do a deep search for the sub-object I want to update, make changes to it and save the root.

However, this does not actually update the sub-object and I can't just do an update on it in the traditional sense because it's not its own document in Mongo, it's just nested. How can I achieve this?

I hope I've explained what I'm trying to do well enough.


if i understand you, i think that if you use dbref annotation, morphia do this automatically... but i'm not sure.

dbref will automatically do reference an document in another, "like" a "normal" relacional reference, if i understand, you're referencing documents manually...

try testing this, and tell us what you get.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜