Require Spring boot application with multiple data source configured.
Multiple data source configuration is working with separate datasource, entityManager and transactionManager.
Also hibernate naming configuration is working with single data source with below configuration.
spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
The above configuration can be provided with JPA properties to entityManager. But not able to add dynamic table name (from application.properties) in SpringPhysicalNamingStrategy.
I have created a custom physical naming strategy. It can change names with environment variables. Also, it can change column names too. Name identifier will be decided by the database catalog name. You can change selection criteria with using
jdbcEnvironment. If you put any criteria option text will be the property value.Application Properties
User Entity
DynamicPhysicalNamingStrategy
Test