HIbernate 5: generator class=“sequence” not working

前端 未结 3 548
遥遥无期
遥遥无期 2021-02-09 04:22

I have following mapping:

    
        
            

        
3条回答
  •  爱一瞬间的悲伤
    2021-02-09 04:40

    I also encountered this problem when migrating from Hibernate 4.3.10 to Hibernate 5.0.4. Like maksim2020, I replaced instances of with . However, to preserve the id sequence for the affected tables I also had to write a sql migration script which set the default value for the column to be the next value of the existing sequence. In PostgreSQL this is done as follows:

    ALTER TABLE ONLY affected_table ALTER COLUMN affected_id SET DEFAULT nextval('original_sequence'::regclass);
    

提交回复
热议问题