I am working on project where I am using hibernate to perform CRUD operations. I have user model and I am trying to insert the information but keeping getting this error
Hibernate: insert into APPUSER (dob, email, firstName, lastName, password) values (?, ?, ?, ?, ?)
Jun 21, 2016 2:17:07 AM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 1400, SQLState: 23000
Jun 21, 2016 2:17:07 AM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: ORA-01400: cannot insert NULL into ("MYAPP8785"."APPUSER"."ID")
The user model looks like
@Entity
@Table(name="APPUSER")
public class AppUser {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Email
@Size(max = 50)
private String email;
@Column
private String dob;
@Column
private String firstName;
@Column
private String lastName;
@Column(name = "password", nullable = false)
private String password;
}
Hibernate properties like
properties.put("hibernate.dialect","org.hibernate.dialect.MySQLDialect");
//properties.put("hibernate.current_session_context_class","thread");
properties.put("hibernate.hbm2ddl.auto","update");
properties.put("hibernate.show_sql","true");
I am under the impression that hibernate would auto generate id for me and insert them using sequence