Reputation: 22017
Account
has a Origin
via @ManyToOne
Origin
s has Shadow
s via @OneToMany
With given Root<Account>
, How can I join those Shadow
s so that I can put some conditions for them on where?
final Root<Account> account;
final Path<Origin> origin = account.get(Account_.origin);
Upvotes: 1
Views: 164
Reputation: 16273
Provided that the @OneToMany
property in Origin
entity is called shadows
, you need to use Join as follows:
Join<Origin, Shadow> shadows = origin.join(Origin_.shadows);
Then, you can write conditions on Shadow
s properties like in this trivial String case, since Join<Z,X>
has Path<X>
as SuperInterface:
String name;
Predicate condition = criteriaBuilder.equals(shadows.get(Shadow_.name, name));
Upvotes: 1