title: Spring JPA Repository findBy foreign key directly with POJO instead of data member of class
body: <p>I have a <code>Paper</code> entity and <code>Student</code> entity defined as below<br>
  <strong>Paper.java</strong></p>
  
  <pre><code>public class Paper extends BaseEntity
  {
      ...
  
      @ManyToOne
      @JoinColumn(name = "student", nullable = false, referencedColumnName = "tp")
      private Student student;
  
      ...
  }
  </code></pre>
  
  <p><strong>Student.java</strong></p>
  
  <pre><code>public class Student extends BaseEntity
  {
      ...
  }
  </code></pre>
  
  <p>I create a <code>PaperRepository</code> for <code>Paper</code> class, I want to find Paper by Student, so a query method is created as this:</p>
  
  <pre><code>List&lt;Paper&gt; findByStudentOrderByDateSubmitted(Student student);
  </code></pre>
  
  <p>But this method returns an empty result. I have to specify the method to find by student id like below:<br></p>
  
  <pre><code>List&lt;Paper&gt; findByAndStudent_IdOrderByDateSubmitted(String id);
  </code></pre>
  
  <p>With this method, it works. Is it possible to find by foreign class, instead of the data member of the foreign class?</p>