@Id
@GeneratedValue
public Long getId() {
return id;
}
默认是自增从1开始。
如果设置初始值自增需要使用
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE,generator="mySeqGenerator")
@SequenceGenerator(name = "mySeqGenerator", sequenceName = "t_teacher_sequence", initialValue = 1000, allocationSize = 50)
public int getId(){
return id;
}
但是这种sequence不支持mysql,
Go directly to change the AUTO_INCREMENT value of the table