Generate DDL with spring boot using a custom delimiter

前端 未结 5 1849
臣服心动
臣服心动 2020-12-31 20:27

I want generate create and drop ddl scripts using spring boot v1.4.3 with JPA - Hibernate 5.0.11.

Most answers I found use the javax.persistence.schema-generati

5条回答
  •  攒了一身酷
    2020-12-31 21:17

    What I found out is that the sessionFactoryholds the schemaExport values like createSQL, dropSQL, outputFile and delimiter.

    The sessionFactory as a Bean can be created like that and is then available for autowiring:

    ....
    
    @Autowired
    private EntityManagerFactory entityManagerFactory;
    
    @Bean
    public SessionFactory sessionFactory() {
        if (entityManagerFactory.unwrap(SessionFactory.class) == null) {
            throw new NullPointerException("factory is not a hibernate factory");
        }
        return entityManagerFactory.unwrap(SessionFactory.class);
    }
    

    That is not a working solution but could help you to manually configure the schemaExport using sessionFactory. I dont find a solution for just using the properties and setting the delimiter just there. But could be a little helper for finding the working solution.

    If I find more useful infos I will update my answer.

提交回复
热议问题