最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

spring.jpa.hibernate.ddl-auto: update is not creating database sequences - Stack Overflow

programmeradmin5浏览0评论

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;
}
发布评论

评论列表(0)

  1. 暂无评论