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 badges1 Answer
Reset to default 0You 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;
}