title: HIbernate doesn't see a column
body: <p>I've got the following table in a PostgreSQL database:</p>
  
  <pre><code>CREATE TABLE users
  (
  id INTEGER PRIMARY KEY NOT NULL,
  name VARCHAR(64) NOT NULL,
  age INTEGER NOT NULL
  );
  CREATE UNIQUE INDEX users_name_uindex ON users (name);
  </code></pre>
  
  <p>And the following Hibernate entity mapping:</p>
  
  <pre><code>@Entity
  public class User implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(generator="increment")
      @GenericGenerator(name="increment", strategy = "increment")
      private int id;
  
      @Column (name = "name")
      private String name;
  
      @Column (name = "age")
      private int age;
  
      public User() {}
      // setters and getters
  }
  </code></pre>
  
  <p>And a function to get all users from table</p>
  
  <pre><code>@Repository
  public class UserDAO {
  
      @PersistenceContext
      EntityManager em;
  
      public List&lt;User&gt; getAll() {
          CriteriaBuilder cb = em.getCriteriaBuilder();
          CriteriaQuery&lt;User&gt; cq = cb.createQuery(User.class);
          Root&lt;User&gt; fromUser = cq.from(User.class);
          cq.select(fromUser);
          TypedQuery&lt;User&gt; tq = em.createQuery(cq);
  
          return tq.getResultList();
      }
  }
  </code></pre>
  
  <p>When I run this function, the following SQL gets run (outputted using show_sql):</p>
  
  <pre><code>select
      user0_.id as id1_,
      user0_.age as age1_,
      user0_.name as name1_ 
  from
      User user0_
  </code></pre>
  
  <p>And the following error occurs:</p>
  
  <pre><code>WARN : org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 42703
  ERROR: org.hibernate.util.JDBCExceptionReporter - ERROR: column user0_.id not exists
  </code></pre>
  
  <p>Does anyone know why this is happening?</p>