I build a Spring-Boot application that accesses a Database and extracts data from it. Everything is working fine, but I want to configure the table names from an external .p
Spring boot solution: Create below class
@Configuration
public class CustomPhysicalNamingStrategy extends SpringPhysicalNamingStrategy{
@Value("${table.name}")
private String tableName;
@Override
public Identifier toPhysicalTableName(final Identifier identifier, final JdbcEnvironment jdbcEnv) {
return Identifier.toIdentifier(tableName);
}
}
Add below property to application.properties:
spring.jpa.properties.hibernate.physical_naming_strategy=.CustomPhysicalNamingStrategy
table.name=product