[PersistenceException: Error getting sequence nextval]

前端 未结 3 969
忘掉有多难
忘掉有多难 2021-01-18 15:57

i am getting this error while trying to save data into model in db.

@Entity
public class User extends Model {
   @Required
   public String name; 
   @Email         


        
3条回答
  •  逝去的感伤
    2021-01-18 16:23

    This worked for me:

    @Entity
    @Table(name = "table", schema = "schema")
    public class Bean extends Model{
    
       @Id
       @Column(name = "idcolumn")
       @SequenceGenerator(name="gen", sequenceName="schema.table_idcolumn_seq",allocationSize=1) 
       @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "gen")
       private int id;
    }
    

    When using the SequenceGenerator, please mind this bug in Hibernate: https://hibernate.atlassian.net/browse/HHH-7232

    It forces you to write the schema directly into the sequenceName instead of using the schema field in the SequenceGenerator annotation.

提交回复
热议问题