title: Java hibernate Joined inheritence (id not found)
body: <p>Sorry for my English, it's not my native language and it's allready 2 o'clock, so can't think strait now.
  Now i have next problem while using hibernate with Java and PostgreSQL:
  I have entity Human and User as follows (with annotation mappings):</p>
  
  <pre><code>    @Inheritance(strategy = InheritanceType.JOINED)
      public class Human implements Serializable{
          private static final long serialVersionUID = 1L;
          public static enum Gender{
              Male,
              Female}
          @Id
          @GeneratedValue
          private Integer id;
          @Enumerated(EnumType.STRING)
          private Gender gender;
          @Column
          @Temporal(TemporalType.DATE)
          private Date dateOfBirth;
          private String firstName;
          private String middleName;
          private String lastName;
          // getters,setters
      }
  
      @Entity
      @PrimaryKeyJoinColumn
      public class User extends Human{
          private static final long serialVersionUID= 1L;
          @Column
          @Temporal(TemporalType.DATE)
          private Date registrationDate;
          private Boolean activationStatus;
          private String activationCode;
          private String login;
          private String password;
          private String sessionCode;
          private String email;
          private String country;
          private String city;
          private String avatarURL;
          private String description;
          // getters,setters
      }
  </code></pre>
  
  <p>And database structure as follows:</p>
  
  <pre><code>human
  (
    dateofbirth date NOT NULL,
    firstname text NOT NULL,
    middlename text NOT NULL,
    lastname text NOT NULL,
    id serial NOT NULL,
    gender text,
    CONSTRAINT "Human_id" PRIMARY KEY (id )
  )
  "user"
  (
    login text NOT NULL,
    password text NOT NULL,
    activationcode text NOT NULL,
    activationstatus status NOT NULL,
    avatarurl text NOT NULL,
    city text NOT NULL,
    country text NOT NULL,
    description text NOT NULL,
    registrationdate date NOT NULL,
    email text NOT NULL,
    id integer,
    CONSTRAINT uid PRIMARY KEY (id )
  )
  </code></pre>
  
  <p>When I try to run my project (simple unit test) i get next error:</p>
  
  <pre><code>    org.postgresql.util.PSQLException: ERROR: column human0_1_.id does not exist
        Позиция: 778
          at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
          at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
          at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
          at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
          at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
          at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273)
          at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
          at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
          at org.hibernate.loader.Loader.doQuery(Loader.java:674)
          at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
          at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
          at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
          at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
          at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044)
          at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
          at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
          at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
          at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
          at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
          at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
          at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
          at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
          at org.tempos.server.modules.users.HumanTest.testGetId(HumanTest.java:31)
  ...
  </code></pre>
  
  <p>(I cut out tail of log, while it responds on invokin JUnit methods).</p>
  
  <p>Generated query (that fails):</p>
  
  <pre><code>select human0_.id as id3_0_, human0_.dateOfBirth as dateOfBi2_3_0_, human0_.firstName as firstName3_0_, human0_.gender as gender3_0_, human0_.lastName as lastName3_0_, human0_.middleName as middleName3_0_, human0_1_.activationCode as activati1_4_0_, human0_1_.activationStatus as activati2_4_0_, human0_1_.avatarURL as avatarURL4_0_, human0_1_.city as city4_0_, human0_1_.country as country4_0_, human0_1_.description as descript6_4_0_, human0_1_.email as email4_0_, human0_1_.login as login4_0_, human0_1_.password as password4_0_, human0_1_.registrationDate as registr10_4_0_, human0_1_.sessionCode as session11_4_0_, case when human0_1_.id is not null then 1 when human0_.id is not null then 0 end as clazz_0_ from Human human0_ left outer join User human0_1_ on human0_.id=human0_1_.id where human0_.id=?
  </code></pre>
  
  <p>As one can see, it tries to JOIN columns on human1_1_.id (originally User.id), but it isn't specified and obtained in SELECT part of query.</p>
  
  <p>What I was tried:</p>
  
  <ol>
  <li>Creating @Column private Integer id in class User (got Annotation
  parser exception for overriding primary column for class);</li>
  <li>Created @Column private Integer hid in class User and set it as
      PrimaryKeyJoinColumn (but i got (should be mapped with
      insert="false" update="false") even if I map it as
      @JoinColumn(insertable=false,updatable=false,referencedColumnName="id"));</li>
  <li>Created column "hid" and pointed it as PrimaryKeyJoinColumn in
      annotation to column itself, not whole class (got the same error as
      in original, column "human0_1_.id not found);</li>
  </ol>
  
  <p>Anyone, give me some ideas please!</p>