hi,
I'm trying to import some data into postgresql database, the entity like :
@Entity
@Table(name = "user", schema = "public")
public class User implements java.io.Serializable {
private Integer id;
private String username;
private String password;
@Id
@SequenceGenerator(name = "user_seq", sequenceName = "user_id_seq", allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_seq")
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
......
}
And import.sql like :
insert into user(username,password) values('admin','admin');
The problem is, hibernate will automatically generate the id field of user table as type integer, not type serial, so import.sql will generate error:
Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "id" violates not-null constraint
So, how to let hibernate to generate the correct id field (serial type, not integer type)?
Thanks in advance!