I have a model class that maps to a postgres database using sleep mode. My model class:
@Entity @Table(name="USER") public class User { @Id @GeneratedValue @Column(name="id") private long id; @Column(name="username", unique=true) private String username; @Column(name="email") private String email; @Column(name="created") private Timestamp created; public User(long id, String username, String email) { this.id = id; this.username = username; this.email = email; } }
I am trying to get a user with username adam using the following query:
tx = session.beginTransaction(); TypedQuery<User> query = session.createQuery("FROM User u WHERE u.username = :username", User.class).setParameter("username", "adam"); user = query.getSingleResult();
I get an exception that says:
org.postgresql.util.PSQLException: ERROR: column user0_.id does not exist
My database from the bash shell looks like this:

How does hibernate map class class attributes to table columns? Is it only compatible with the @Column(name="username") parameter @Column(name="username") or is it also trying to match based on data types and restrictions, such as a unique / automatic increment?
swdon source share