title: JPA @JoinColumn and relationship between entities
body: <p>In this example from <a href="https://docs.oracle.com/javaee/7/tutorial/persistence-criteria002.htm" rel="nofollow">https://docs.oracle.com/javaee/7/tutorial/persistence-criteria002.htm</a></p>
  
  <pre><code>@Entity
  public class Pet {
      @Id
      protected Long id;
      protected String name;
      protected String color;
  
      @ManyToOne
      protected Set&lt;Person&gt; owners;
      ...
  }
  </code></pre>
  
  <p>I have two questions on this:</p>
  
  <p>1) Why isn't there a @JoinColumn annotation below @ManyToOne?</p>
  
  <p>2) Why isn't there a qualifier in @ManyToOne( targetEntity = Person.class )?</p>
  
  <p>3) Does this @ManyToOne mean that many Persons map to one Pet? If that's the case, why is it Set owners? I thought it should be just </p>
  
  <pre><code>@ManyToOne
  protected Person owner;
  </code></pre>
  
  <p>In this example:</p>
  
  <pre><code>@Entity
  public class Company {
      @OneToMany(fetch = FetchType.LAZY, mappedBy = "company")
      private List&lt;Branch&gt; branches;
  }
  
  @Entity
  public class Branch {
      @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = "companyId")
      private Company company;
  }
  </code></pre>
  
  <p>In the "@JoinColumn(name = "companyId")", why isn't there " referencedColumnName =id"? Is it valid?</p>