gpt4 book ai didi

java - 独立的 JPA 序列

转载 作者:行者123 更新时间:2023-12-04 08:47:48 31 4
gpt4 key购买 nike

通过 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/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com