title: InheritanceType.JOINED, @PrimaryKeyJoinColumn and nested subclasses
body: <p>I am getting started with Hibernate have a question about InheritanceType.JOINED and @PrimaryKeyJoinColumn.</p>
  
  <p>Given the below database tables where employee references person and manager references employee:</p>
  
  <pre><code>create table person (person_id int(10) auto_increment, 
                       name varchar(100),
                       primary key (person_id));
  
  create table employee (employee_id int(10) auto_increment,
                         person_id int(10),
                         salary int(10),
                         primary key (employee_id));
  
  create table manager (manager_id int(10) auto_increment,
                        employee_id int(10),
                        shares int(10),
                        primary key (manager_id));
  </code></pre>
  
  <p>I can create the first two classes for Person and Employee as follows:</p>
  
  <pre><code>@Entity
  @Table(name="person")
  @Inheritance(strategy=InheritanceType.JOINED)
  public class Person {
  
      @Id
      @GeneratedValue
      @Column(name="person_id")
      private int personId;
  
      @Column(name="name")
      private String name;
  }
  
  
  @Entity
  @Table(name="employee")
  @PrimaryKeyJoinColumn(name="person_id")
  public class Employee extends Person {
  
      @GeneratedValue
      @Column(name="employee_id")
      private int employeeId;
  
      @Column(name="salary")
      private int salary;
  }
  </code></pre>
  
  <p>When it comes to the Manager class I am not sure which value to use for the @PrimaryKeyJoinColumn. From reading the JPA spec I should be using only one id throughout the superclass/subclass/subclass hierarchy, which I suspect should be person_id.</p>
  
  <p>Should I remove the employee_id column from the manager table and replace it with person_id? The reason I ask is that it seems natural to have "cascading" primary keys in the database (i.e. manager does not directly refer to person) but I believe Hibernate requires that all child subclasses (however "deep") contain a foreign key back to the superclass. Some confirmation on my assertions would be really useful.</p>