I upgraded from spring boot 2.0.6 to 2.1.0, but there was an error as follows:
_The method get Hibernate Properties (Hibernate Settings) is undefined for the type JpaProperties_
It seems that there is no getHibernateProperties (HibernateSettings) method under the class org.springframework.boot.autoconfigure.orm.jpa.JpaProperties.
I looked at https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes and it didn't mention any changes to this class here.
getHibernateProperties(HibernateSettings)
was removed from JpaProperties
in this commit. It isn't mentioned in the release notes as we do not expect code outside of Spring Boot to call that method.
Can you please share the complete stack trace of the failure?
I do not have the stack trace, just code compilation failed.
You could inject and use HibernateProperties
in place of JpaProperties.getHibernateProperties()
but I suspect there should be no need to do so. However, I can't see exactly what you're trying to do based on that small snippet of configuration. Can you please take a step back and describe why you are configuring your own LocalContainerEntityManagerFactoryBean
?
We have a requirement that each HTTP request needs to access different data sources based on a parameter, such as region, so I configuring my own LocalContainerEntityManagerFactoryBean to achieve this. Code attached.
Thanks. So it appears that you do need multiple DataSources and, therefore, that you need to configure your own LocalContainerEntityManagerFactoryBean
. You can do so like this with Spring Boot 2.1:
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
EntityManagerFactoryBuilder builder, JpaProperties jpaProperties,
HibernateProperties hibernateProperties) {
Map<String, Object> properties = hibernateProperties.determineHibernateProperties(
jpaProperties.getProperties(), new HibernateSettings());
return builder.dataSource(dynamicDataSource()).properties(properties)
.packages("com.openstring.resource.common.entity").build();
}
I've added an entry to the release notes as well.
Hi @wilkinsona
Please pardon me for commenting on a closed thread.
I have an issue in Springboot migration from 1.5.9 to 2.3.1 related to JdbcTemplates's NativeJdbcExtractor.
I have used your answer to Migrate hibernate code but stuck with JdbcTemplate.
I have linked the StackOverflow Question,
https://stackoverflow.com/questions/63055393/springboot-2-3-1-dynamically-update-jdbc-templates-schema-in-multi-tenant-envir?sem=2
It's basically related to the dynamic update of JdbcTemplate's schema based on the REST call.
Is it even possible on Springboot2?
Should I get rid of JdbcTemplate? (Need a lot of coding and testing effort)
Should I stop migrating?
Please help.
Most helpful comment
Thanks. So it appears that you do need multiple DataSources and, therefore, that you need to configure your own
LocalContainerEntityManagerFactoryBean
. You can do so like this with Spring Boot 2.1:I've added an entry to the release notes as well.