私はこれに似たモルヒネスキーマを持っています:
@Entity
class BlogEntry {
@Embedded
List<BlogComment> comments
}
@Embedded
class BlogComment {
String content
Long authorId
}
(説明のために上記のコード)
新しいコンテンツで更新するために、特定のBlogCommentを取得しようとしています。対応するBlogEntryオブジェクトが利用可能であり、authorIdがあります。これは、この質問の目的のために、これら2つを合わせて正しいBlogCommentを一意に識別するのに十分であるとしましょう。
私の質問は、BlogCommentにはその「親」BlogEntryオブジェクトへの参照が明示的に含まれていないため、このBlogCommentを取得するためのモーフィアクエリを作成するにはどうすればよいですか?何かのようなもの:
//fetch the unique comment corresponding to this blog entry and this author ID.
BlogComment comment = ds.find(BlogComment.class, "blogEntryId =", blogEntry.id)
.filter("authorId", authorId)
.get();