I have a spring application configured with spring boot and config annotations.
JPA configuration is:
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories
public class JpaConfiguration {
@Bean
public DataSource dataSource() {
return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.DERBY).build();
}
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource,
JpaVendorAdapter jpaVendorAdapter) {
LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
lef.setDataSource(dataSource);
lef.setJpaVendorAdapter(jpaVendorAdapter);
lef.setPackagesToScan( /* "..." */ );
return lef;
}
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
hibernateJpaVendorAdapter.setShowSql(true);
hibernateJpaVendorAdapter.setGenerateDdl(true);
hibernateJpaVendorAdapter.setDatabase(Database.DERBY);
return hibernateJpaVendorAdapter;
}
@Bean
public PlatformTransactionManager transactionManager() {
return new JpaTransactionManager();
}
}
I consistently get in the logs:
[...]
HHH000400: Using dialect: org.hibernate.dialect.DerbyDialect
HHH000430: The DerbyDialect dialect has been deprecated; use one of the version-specific dialects instead
[...]
I tried adding:
@Bean
public DerbyTenSevenDialect jpaDialect() {
return new DerbyTenSevenDialect();
}
but then the returned bean is not compatible with:
LocalContainerEntityManagerFactoryBean lef //.....
lef.setJpaDialect(JpaDialect);
How do I get rid of the deprecation warning?
Just ditch the following line totally (without replacing it with anything else):
hibernateJpaVendorAdapter.setDatabase(Database.DERBY);
That's all I did and Hibernate correctly logged:
Using dialect: org.hibernate.dialect.DerbyTenSevenDialect
After that there is no need of manually defining the Dialect Bean. Hibernate figures out the correct dialect on it's own
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With