jpa mysql 如何id自增初始值?
PHPz
PHPz 2017-04-17 14:50:53
0
1
736
    @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,

PHPz
PHPz

学习是最好的投资!

reply all(1)
伊谢尔伦

Go directly to change the AUTO_INCREMENT value of the table

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!