title: Writing CRUDRepository's findBy() method on a field annotated by JoinColumn
body: <p>I'm kind of new to Spring JPA, so I apologize in advance if my question sounds basic. I have 2 entity objects: OrderInfo, and PersonInfo. The classes are as below:</p>
  
  <pre><code>@Entity
  @Table(name="order_info")
  @NamedQuery(name="OrderInfo.findAll", query="SELECT o FROM OrderInfo o")
  public class OrderInfo implements Serializable {
  
      @Column(name="order_number")
      private String orderNumber;
  
      //bi-directional many-to-one association to PersonInfo
      @ManyToOne
      @JoinColumn(name="person_id")
      private PersonInfo personInfo;
  
      public String getOrderNumber() {
          return this.orderNumber;
      }
  
      public void setOrderNumber(String orderNumber) {
          this.orderNumber = orderNumber;
      }
  
      public PersonInfo getPersonInfo() {
          return this.personInfo;
      }
  
      public void setPersonInfo(PersonInfo personInfo) {
          this.personInfo = personInfo;
      }
  
  
  }
  </code></pre>
  
  <p>And the Person entity:</p>
  
  <pre><code>@Entity
  @Table(name="person_info")
  @NamedQuery(name="PersonInfo.findAll", query="SELECT p FROM PersonInfo p")
  public class PersonInfo implements Serializable {
  
      //bi-directional many-to-one association to OrderInfo
      @OneToMany(mappedBy="personInfo")
      private List&lt;OrderInfo&gt; orderInfos;
  
      public List&lt;OrderInfo&gt; getOrderInfos() {
          return this.orderInfos;
      }
  
      public void setOrderInfos(List&lt;OrderInfo&gt; orderInfos) {
          this.orderInfos = orderInfos;
      }
  
      public OrderInfo addOrderInfo(OrderInfo orderInfo) {
          getOrderInfos().add(orderInfo);
          orderInfo.setPersonInfo(this);
  
          return orderInfo;
      }
  
      public OrderInfo removeOrderInfo(OrderInfo orderInfo) {
          getOrderInfos().remove(orderInfo);
          orderInfo.setPersonInfo(null);
  
          return orderInfo;
      }
  
  }
  </code></pre>
  
  <p>These two classes were auto-generated in Eclipse using JPA's create entityfromtable option. </p>
  
  <p>Now, I'm trying to write a CRUDRepository to get OrderInfo given an orderNumber, and personId. If I had a personId field in the OrderInfo object, I could have written something like </p>
  
  <pre><code>@Repository
  public interface OrderRepository extends CrudRepository&lt;OrderInfo, Integer&gt;{
      public OrderInfo findByPersonIdAndOrderNumber(@Param("personId") Long personId, @Param("orderNumber") String orderNumber);
  
  }
  </code></pre>
  
  <p>However, now the OrderInfo entity does not have a personId. Instead, it has a reference to a Person (Again, I did not write the entity classes. They were auto-generated by Eclipse). How should I write the findBy() method now?</p>
  
  <p>Thanks in advance.</p>