yeswanth a
yeswanth a

Reputation: 1

Spring Data jpa query with Join with where condition

I have two tables

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

Answers (1)

Simon Martinelli
Simon Martinelli

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

Related Questions