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

I have a PostgreSQL database with Spring Boot configured to use:spring.jpa.hibernate.ddl-auto: updateW

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;
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744220149a4563741.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信