Hibernate is generating auto increment alternating id for tables

前端 未结 1 1843
自闭症患者
自闭症患者 2021-01-17 03:05

My environment : Hibernate 5, Java 8, Phpmyadmin in WAMP

Problem: Hibernate creates auto increment id within a table, but the

相关标签:
1条回答
  • 2021-01-17 03:56

    You haven't specified any generator for any of your entities. So Hibernate uses the default one for your database, which consists in using single sequence: hibernate_sequence, to generate the IDs of the entities.

    Annotate your Student id field with something like

    @SequenceGenerator(name = "studentGenerator", sequenceName = "STUDENT_SEQUENCE", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "studentGenerator")
    

    and it will use a dedicated sequence, STUDENT_SEQUENCE, for the Student entity. Do the same (with a different generator and sequence name) for the other entities.

    0 讨论(0)
提交回复
热议问题