title: How to Inner Join using Spring Boot JPA / Hibernate in Repository?
body: <p>I am currently learning spring boot , hibernate and Spring Boot JPA</p>
  
  <p>I developing a Classroom App for coaching centers and institutes  . </p>
  
  <p>In it, students enrolled to multiple courses in a single institute </p>
  
  <p><strong>The Student Entity class :</strong></p>
  
  <pre><code>@Entity
  @Table(name = "student")
  public class Student  {
  
      private String name;
  
      private String dob;
  
      private String gender;
  
      private String address;
  
      private String email;
  
      private Integer mobile;
  
      private String joined;
  
      private Integer instID;
  
      @Id
      private String studentid;
  
      getters and setters()....
  }
  </code></pre>
  
  <p><strong>Course Table Entity class</strong></p>
  
  <pre><code>@Entity
  @Table(name = "courses")
  public class Course {
  
      private String name;
  
      private String description;
  
      private String logo;
  
      private String start;
  
      private String end;
  
      private Integer fee;
      @Id
      private String courseid;
  
  
      private Integer instID;
  
      getters and setters();
  }
  </code></pre>
  
  <p><strong>Enrolled Classes Table's Entity class</strong></p>
  
  <pre><code>public class EnrolledCourses {
  
      @Id
      String enrollID;
  
      String courseid;
      String studentid;
  
      Date joined;
  
      getters  and setters()...
  
  }
  </code></pre>
  
  <p><strong>JPA Repository</strong>   </p>
  
  <pre><code> @Repository
      public interface StudentRepository extends CrudRepository&lt;Student, String&gt; {
          Student findTopByInstIDOrderByStudentidDesc(int instID);
      }
  
  @Repository
  public interface CourseRepository extends CrudRepository&lt;Course,String&gt; {
  }
  
  @Repository
  public interface EnrolledRepository extends CrudRepository&lt;Course,String&gt; {
  }
  </code></pre>
  
  <p><br><br><br>
  <strong>My Need</strong></p>
  
  <p>Now I am retrieving enrolled students for <em>a given course in a given institute</em>... by using this MySQL query</p>
  
  <pre><code>SELECT 
  `enrolled_courses.enrollID`,
  `student.name`, `student.studentid`
  FROM `enrolled_courses`
  INNER JOIN `student`
  WHERE
  `enrolled_courses.studentid` = `student.studentid`
  AND
  `student.instID` = 13
  AND
  `enrolled_courses.courseid` = '13I01C' ;
  </code></pre>
  
  <p><br>
  Now I need to implement this Inner join query in CourseRepository (or enrolledstudent repo) </p>
  
  <p><br><br>
  How to achieve this ? </p>
  
  <p>Please guide me
  <br>
  <br></p>