Reputation: 1
I have two tables
RoleMasterLink
with userId
and RoleId
RoleMaster
with RoleId
and FunctionalRole
I need to achive
Select rm.FunctionalRole from RoleMaster rm join RoleMasterLink rml on rml.RoleId = rm.RoleId where rml.userId='yesh'
User can have many roleIds, I need to get FunctionalRole based on RoleId
How to achive this with Spring Data Jpa, gone through many links but exactly couldn't get.
Upvotes: 0
Views: 2098
Reputation: 36103
Simply add your query in a @Query annotation in your Repository interface:
@Query("Select rm.FunctionalRole from RoleMaster rm join RoleMasterLink rml on rml.RoleId = rm.RoleId where rml.userId= :userId")
String findFunctionalRole(String userId);
Upvotes: 2