I have configured my naming strategy, which works on my local machine but it does not work when I deploy to an EC2 instance.
Properties
private HashMap<String, Object> propertiesMap(){
HashMap<String, Object> properties = new HashMap<>();
properties.put("hibernate.hbm2ddl.auto", "none");
properties.put("hibernate.naming.physical-strategy", "com.beamsolutions.beam.utils.services.DBNamingStrategyManager");
properties.put("hibernate.temp.use_jdbc_metadata_defaults", "false");
properties.put("hibernate.jdbc.lob.non_contextual_creation", "false");
properties.put("hibernate.dialect", "org.hibernate.dialect.MySQL8Dialect");
return properties;
}
@Bean(name="tenantEntityManager")
@Primary
public LocalContainerEntityManagerFactoryBean tenantEntityManager(EntityManagerFactoryBuilder builder,
DataSource dataSource){
return builder.dataSource(dataSource)
.packages("com.beamsolutions.beam.hr_mgt",
"com.beamsolutions.beam.hse_mgt",
"com.beamsolutions.beam.inv_mgt",
"com.beamsolutions.beam.maint_mgt",
"com.beamsolutions.beam.ops_mgt",
"com.beamsolutions.beam.req_mgt",
"com.beamsolutions.beam.dashboard_mgt",
"com.beamsolutions.beam.repos_mgt")
.properties(propertiesMap())
.build();
}
this is the bean where i use the configured jpa properties. I notice that the confgurations are basically ignored and the field names are not affected by the DBNamingStrategyManager
Comment From: wilkinsona
This doesn't look like a Spring Boot problem to me as you're configuring things yourself rather than relying on Boot's auto-configuration. Perhaps you can use trace-level logging or debug your application on EC2 to determine why it's apparently taking a different code path in that environment. I'm going to close this one for now. If the logging or debugging should that this is, in fact, a problem caused by Spring Boot, please add a comment to this issue containing that evidence and we can re-open it and take another look.
Comment From: wilkinsona
I'd also double-check the names of the properties that you're using and that it is working on your local machine. AFAIK, the correct property name for the physical naming strategy is hibernate.physical_naming_strategy.
Comment From: Omololu98
Thank you on the advise