i have the following constellation:
public final class ApplicationUser {
private final @Id
@Wither
long applicationUserId;
@NotNull
@Size(min = 4, max = 20)
private final
String login;
@NotNull
@Email
private final
String eMail;
@Wither
private Set<Privilege> privileges;
}
Now i want to query one ApplicationUser
by its login
which is done by a simple sql Query
.
My question now:
Is there any spring-data-jdbc related thing to jpa´s join fetch so that i can fetch the associated Set<Privilege> privileges
in one declared query?
Or do i have to fire another query like so:
ApplicationUser
by its loginPrivilege
by its foreign key applicationuser
Thank you
Your answer describes the default way to do this. If you want to avoid the extra select you could use a statement that contains the join and use a ResultSetExtractor
to construct your entities.
Pro: More efficient at runtime.
Con: More work for you.