带嵌入式德比的Spring:hibernate dialect弃用

时间:2014-03-30 08:51:48

标签: spring hibernate jpa derby spring-annotations

我有一个配置了spring boot和config注释的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);

如何摆脱弃用警告?

1 个答案:

答案 0 :(得分:7)

完全抛弃以下一行(不用其他任何东西替换):

hibernateJpaVendorAdapter.setDatabase(Database.DERBY);

我所做的一切都是Hibernate正确记录的:

Using dialect: org.hibernate.dialect.DerbyTenSevenDialect

之后,无需手动定义Dialect Bean。 Hibernate在它自己的

上找出了正确的方言