title: Hibernate Joins In Spring boot application
body: <p>I am using Spring boot MVC application with hibernate ORM.</p>
  
  <p>I have a table as student which has foreign keys from other tables.</p>
  
  <p><strong>Student.java:</strong></p>
  
  <pre><code>@Entity
  @Table(name = "STUDENT")
  
  public class student{
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private long STUDENT_ID;   
  
  @OneToOne
  @JoinColumn(name="COURSE_ID")
  private Long COURSE_ID;
  
  @OneToOne
  @JoinColumn(name="ACDYEAR_ID")
  private Long ACDYEAR_ID; 
  
  @OneToOne
  @JoinColumn(name = "SEMESTER_ID")
  private Long SEMESTER_ID;
  }
  </code></pre>
  
  <p><strong>StudentRepository:</strong></p>
  
  <pre><code>@Query(value="SELECT * FROM STUDENT INNER JOIN ACADEMICSYEAR ON      STUDENT.ACDYEAR_ID = ACADEMICSYEAR.ACDYEAR_ID  INNER JOIN ACADEMICSCOURSE ON STUDENT.COURSE_ID = ACADEMICSCOURSE.COURSE_ID where STUDENT_ID=?1",
          nativeQuery=true)
   public STUDENT findOneID(Long id);
  </code></pre>
  
  <p>Same query in sql server returns populated academic year table and course table but here it is giving an error like</p>
  
  <pre><code>   org.hibernate.AnnotationException: @OneToOne or @ManyToOne on com.boot.model.STUDENT.COURSE_ID references an unknown entity: java.lang.Long
  </code></pre>