While working on my first application in Hibernate. When I try to get a User object from the database, I get the following exception:
org.hibernate.TypeMismatchException: The wrong type identifier was provided for the org.cw.form.User class. Expected: class java.lang.Integer, got class java.lang.String in org.hibernate.event.def.DefaultLoadEventListener.onLoad (DefaultLoadEventListener.java:109) in org.hibernate.impl.SessionImpl.fireLoad (SessionImpj.mpj. 906) in org.hibernate.impl.SessionImpl.load (SessionImpl.java:823) in org.hibernate.impl.SessionImpl.load (SessionImpl.java:816)
I created a USERS table with the following postgreSQL:
CREATE SEQUENCE user2_id_seq;
CREATE TABLE USERS(id integer NOT NULL DEFAULT nextval('user2_id_seq'), user_name varchar(45) NOT NULL UNIQUE , password varchar(45) NOT NULL, email varchar(45) NOT NULL, PRIMARY KEY (id));
And the user object is defined as such:
@Entity @Table(name="USERS") public class User {
@Id
@Column(name="ID")
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id;
@Column(name="USER_NAME", unique = true)
private String userName;
@Column(name="PASSWORD")
private String password;
@Column(name="EMAIL")
private String email; .. all the getters and setters...
Am I missing something?