Standalone JPA sequence

Viewed 83

Through SQL one can define a sequence such as CREATE SEQUENCE sequence_name.

Can it be defined using JPA? I only know of sequences defined on attributes of entities. I'd like to avoid creating an entity just to be able to define a sequence.

1 Answers

You can try to create it on start up. From this documentation:

Spring Boot can automatically create the schema (DDL scripts) of your DataSource and initialize it (DML scripts). It loads SQL from the standard root classpath locations: schema.sql and data.sql

For example put SEQUENCE creation into data.sql

Related