Skip to content

EntityManagerFactoryBuilder does not apply spring.jpa.hibernate customizations automatically #3654

@eepstein

Description

@eepstein

When using a single data source and entity manager in a Spring Boot JPA project, the hibernate settings are picked up from the application properties (e.g., the application.yml file) and applied as expected.

In the case of multiple data source and entity managers, the naming_strategy setting is not applied and thus we get the default naming strategy. A minor bug with a likely quick fix I imagine.

I've put together a sample project showing the issue:

https://github.com/eepstein/multids-demo

(which was forked from https://github.com/gratiartis/multids-demo)

The relevant lines are in the FooConfig and BarConfig classes. For example, from com.sctrcd.multidsdemo.integration.config.foo.FooConfig:

                    // This is to work-around a bug in Spring boot, which is not setting the naming strategy when there
                    // are multiple data sources and entity managers.
            .properties(Collections.singletonMap("hibernate.ejb.naming_strategy",
                    jpaProperties.getHibernate().getNamingStrategy()))

If you comment out that line you'll see an assertion in the test will fail, even though the naming strategy is being correctly set in the application-test.yml file in the test resources folder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions