すべての子がプロパティに一致する親を選択するために、Hibernate (JPA) クエリを作成しようとしています。
実用的な例を作りましょう...
私は、すべての子供が金髪である父親を選びたい. 一人でも黒髪なら父親は選ばれない。
クエリはどのようになりますか? 前もって感謝します!
多分このようなものがうまくいくでしょう:
From Father f
where not exists (select c from f.children c where not c.hair = "BLONDE");
ただのアイデア...
これも機能するはずで、少しきれいに見えます。
SELECT p from Parent p join p.children c where c.haircolor = 'blonde';
http://openjpa.apache.org/builds/1.1.0/docs/jpa_langref.html#jpa_langref_all_anyALL
を
参照して、これを試してください。
select p from parent where 'blonde'=all(parent.children.haircolor)