I using spring boot and test container init db. I using postgresSql 12.1
My entity look like
@Entity
@Table(name = "student")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Student{
@Id
public String studentId;
@Column
public Int age;
...
}
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL94Dialect
spring.jpa.show-sql=true
I set jpa ddl-auto create-drop but when i run test container, spring auto convert primary studentId to serial. I don't know why. I want keep studentId with type String.
Log: Create table student (student_id serial,age int)....
When i insert data looklike
INSERT INTO TABLE student (student_id,age) VALUES ("abc",1)
spring throw exception because it not correct type.
Why spring auto convert primary key String to serial anh how to insert value string into field student_id. I want string don't want serial. How to fixed it.
Aucun commentaire:
Enregistrer un commentaire