java - Why does this sequence generator not create a database table in Spring Boot? -


@entity @table(name = "addition_type") public class additiontype {     @id     @sequencegenerator(name = "addition_type_id_seq", sequencename = "addition_type_id_seq", allocationsize = 1)     @generatedvalue(strategy = generationtype.auto, generator = "addition_type_id_seq")     @column(name = "id")     private int id;      @column(name = "code")     private string code;      @column(name = "name")     private string name;      @column(name = "sinhala_name")     private string sinhalaname;      @column(name = "report_name")     private string reportname;      @column(name = "status")     private int status;      @manytoone     @joincolumn(referencedcolumnname = "id")     private companyinfo companyinfo;      // there not show getter , setter } 

when use class in spring, 2 database tables generated: additiontype table entity, , addition_type_id_seq table corresponding sequence generator. additiontype table had columns: id, name, code ..., , other table had next value of id.

when use class in spring boot did not create 2 tables that. additiontype table created. why sequencegenerator not working in spring boot?

as mysql dialect doesnt support sequences:

we can make use of table generator strategy define sequences :

    @id     @tablegenerator(name = "addition_type_id_seq", allocationsize = 1, table = "addition_type_sequences",                 pkcolumnname = "seq_name",                         valuecolumnname = "seq_number",                 pkcolumnvalue = "sequence")     @generatedvalue(strategy = generationtype.table, generator = "addition_type_id_seq")     @column(name = "id")     private int id; 

this ensure creating 2 tables : addition_type_sequences , addition_type


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -