Heim  >  Fragen und Antworten  >  Hauptteil

jpa mysql 如何id自增初始值?

    @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,

PHPzPHPz2743 Tage vor732

Antworte allen(1)Ich werde antworten

  • 伊谢尔伦

    伊谢尔伦2017-04-17 14:52:53

    直接去改表的 AUTO_INCREMENT 值吧

    Antwort
    0
  • StornierenAntwort