jpa操作postgres
小于 1 分钟
jpa操作postgres
设置自增的主键(推荐使用identity,而不是serial)
方法1
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false,columnDefinition = "serial")
private Long id;
方法2
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "student_id_seq")
@SequenceGenerator(name = "student_id_seq", sequenceName = "student_id_seq")
@Column(name = "id")
private Long id;