admin管理员组

文章数量:1410737

I have a PostgreSQL database with Spring Boot configured to use:

spring.jpa.hibernate.ddl-auto: update

When I start Spring Boot app. Tables are created but sequences configured into entities are not.

I tried with spring.jpa.generate-ddl: true with results in created sequences.

Do you know why this setting is not working for database sequinces?

I have a PostgreSQL database with Spring Boot configured to use:

spring.jpa.hibernate.ddl-auto: update

When I start Spring Boot app. Tables are created but sequences configured into entities are not.

I tried with spring.jpa.generate-ddl: true with results in created sequences.

Do you know why this setting is not working for database sequinces?

Share Improve this question asked Mar 25 at 2:11 Peter PenzovPeter Penzov 1,608156 gold badges499 silver badges907 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You need to explicitly define the sequences in your entity class:

@Entity
public class Entity {
    @Id
    @SequenceGenerator(name="seq",sequenceName="your_seq")        
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq")               
    private Integer id;
}

本文标签: springjpahibernateddlauto update is not creating database sequencesStack Overflow