How to get the All table metadata in spring boot - JPA - hibernate?

后端 未结 3 453
逝去的感伤
逝去的感伤 2021-01-14 04:09

I need to get META information of All the tables present in my schema dynamically , Meta infos are such as table , entity ,column name etc.

I have f

3条回答
  •  伪装坚强ぢ
    2021-01-14 05:06

    In Spring Boot, spring.jpa.properties points to a Map, so it can only contain String values.

    However in Hibernate, when the EntityManagerFactoryBuilderImpl reads hibernate.integrator_provider it expects to find an instance of IntegratorProvider and not a Class name, hence the exception.

    You can however add a bean that implements HibernatePropertiesCustomizer to add the IntegrationProvider instance to the Hibernate properties:

    @Component
    public class HibernateConfig implements HibernatePropertiesCustomizer {
    
        @Override
        public void customize(Map hibernateProperties) {
            hibernateProperties.put("hibernate.integrator_provider",
                    (IntegratorProvider) () -> Collections.singletonList(MetadataExtractorIntegrator.INSTANCE));
        }
    }
    

    I have created a working example in this repository.

提交回复
热议问题