通过 SQL,我们可以定义一个序列,例如 CREATE SEQUENCE sequence_name
。
可以用JPA定义吗?我只知道在实体属性上定义的序列。我想避免仅仅为了定义序列而创建实体。
最佳答案
您可以尝试在启动时创建它。 来自 this文档:
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
例如将SEQUENCE创建放入data.sql
关于java - 独立 JPA 序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64222596/