相关疑难解决方法(0)

使用自定义分隔符生成具有弹簧引导的DDL

我想使用带有JPA - Hibernate 5.0.11的spring boot v1.4.3生成create和drop ddl脚本.

我找到的大多数答案都使用了javax.persistence.schema-generation属性.例如/sf/answers/2587649361/

这种方法的问题是它输出没有分隔符的sql语句.例如

create table ... (...)
create table ... (...)
Run Code Online (Sandbox Code Playgroud)

我希望它用分隔符输出语句 ;

create table ... (...);
create table ... (...);
Run Code Online (Sandbox Code Playgroud)

但我找不到任何javax.persistence.schema-generation属性来配置它.

所以我想使用SchemaExportfrom hibernate,因为你可以设置delimiter属性.但要创建一个SchemaExport我需要一个MetadataImplementor(非删除的api).

我无法弄清楚如何MetadataImplementor从春季靴子中获得一个.

有没有人知道是否有

  • javax.persistence.schema-generation用于定义分隔符的属性
  • 或者如何创建SchemaExport(获取依赖项)
  • 还是有其他解决方案?

这是您可以使用的一些代码

@SpringBootApplication
@ComponentScan(basePackageClasses = Application.class)
@EntityScan(basePackageClasses = User.class)
public class Application {

    @Bean
    public ApplicationRunner getApplicationRunner() {
        return new ApplicationRunner() {

            public void run(ApplicationArguments args) throws Exception …
Run Code Online (Sandbox Code Playgroud)

ddl spring hibernate spring-data-jpa spring-boot

7
推荐指数
2
解决办法
2909
查看次数

标签 统计

ddl ×1

hibernate ×1

spring ×1

spring-boot ×1

spring-data-jpa ×1