gpt4 book ai didi

带有嵌入式 Derby 的 Spring : hibernate dialect deprecation

转载 作者:行者123 更新时间:2023-12-02 11:01:31 25 4
gpt4 key购买 nike

我有一个使用 Spring Boot 和配置注释配置的 Spring 应用程序。

JPA 配置为:

@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();
}
}

我一直在日志中:

[...]
HHH000400: Using dialect: org.hibernate.dialect.DerbyDialect
HHH000430: The DerbyDialect dialect has been deprecated; use one of the version-specific dialects instead
[...]

我尝试添加:

@Bean
public DerbyTenSevenDialect jpaDialect() {
return new DerbyTenSevenDialect();
}

但是返回的 bean 与以下内容不兼容:

LocalContainerEntityManagerFactoryBean lef //.....
lef.setJpaDialect(JpaDialect);

如何消除弃用警告?

最佳答案

只需完全放弃以下行(无需用其他任何内容替换):

hibernateJpaVendorAdapter.setDatabase(Database.DERBY);

这就是我所做的一切,Hibernate 已正确记录:

Using dialect: org.hibernate.dialect.DerbyTenSevenDialect

之后就不需要手动定义方言Bean了。 Hibernate 自己找出正确的方言

关于带有嵌入式 Derby 的 Spring : hibernate dialect deprecation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22742068/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com