- それぞれ
AccountにOriginビアがあります@ManyToOne - 各
OriginsにはShadowsviaがあります@OneToMany
与えられた状態Root<Account>で、どのようにそれらに参加Shadowして、どこにそれらの条件を設定できるようにすることができますか?
final Root<Account> account;
final Path<Origin> origin = account.get(Account_.origin);
AccountにOriginビアがあります@ManyToOneOriginsにはShadowsviaがあります@OneToMany与えられた状態Root<Account>で、どのようにそれらに参加Shadowして、どこにそれらの条件を設定できるようにすることができますか?
final Root<Account> account;
final Path<Origin> origin = account.get(Account_.origin);
エンティティの@OneToManyプロパティが呼び出される場合、次のように結合を使用する必要があります。Originshadows
Join<Origin, Shadow> shadows = origin.join(Origin_.shadows);
次に、Shadowこの簡単な文字列の場合のように、プロパティに条件を記述できます。これは、Join<Z,X>がPath<X>SuperInterfaceであるためです。
String name;
Predicate condition = criteriaBuilder.equals(shadows.get(Shadow_.name, name));