我想检索一个对象,基于一个对象的 id(或其他单个字段),该对象与我要检索的对象嵌套 2 个级别。一个例子来证明:
我想查找特定用户评论过的所有博客文章。
Blog
List<Comment>
ignoredField1
ignoredField2
User
id
name
ignoredField3
评论和用户由其父对象@Referenced。
阅读这篇文章后 http://groups.google.com/group/morphia/browse_thread/thread/57090ef1bd2f3e74?pli=1
我了解如何找到带有 ignoreField1/2 具有特定价值的评论的博客,但我想进一步导航。
我尝试了以下方法,但是因为比较了所有评论字段,所以没有匹配
q.field("comments").hasThisElement(new Comment(new User("name")));