首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不一致的hibernate方言错误,使用ipconfig /renew。

不一致的hibernate方言错误,使用ipconfig /renew。
EN

Stack Overflow用户
提问于 2016-10-03 10:10:47
回答 1查看 199关注 0票数 0

这是我的第一个问题。我会尽量具体的。

首先,我知道有很多关于这个错误的主题,有些是带有解决方案的,,但我的情况不同,因为我不是每次都有这个错误,在cmd中输入ipconfig /renew之后,它就消失了一段时间。那么,现在来谈谈细节。

我在Windows 7工作。

这是我的数据源配置:

代码语言:javascript
复制
package ...;

import ...;

@Configuration
public class DataSourceConfig {

  @Value("${db.url}") private String url;
  @Value("${db.user}") private String user;
  @Value("${db.pass}") private String pass;
  @Value("${db.poolSize.init}") private int initPoolSize;
  @Value("${db.poolSize.min}") private int minPoolSize;
  @Value("${db.poolSize.max}") private int maxPoolSize;
  @Value("${db.statements.max}") private int maxStatements;
  @Value("${db.idleTime.max}") private int maxIdleTime;
  @Value("${db.checkoutTimeout}") private int checkoutTimeout;

 @Bean
  public DataSource oracleDataSource() throws SQLException {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    dataSource.setJdbcUrl(url);
    dataSource.setUser(user);
    dataSource.setPassword(pass);
    dataSource.setInitialPoolSize(initPoolSize);
    dataSource.setMaxPoolSize(maxPoolSize);
    dataSource.setMinPoolSize(minPoolSize);
    dataSource.setMaxIdleTime(maxIdleTime);
    dataSource.setMaxStatements(maxStatements);
    dataSource.setCheckoutTimeout(checkoutTimeout);

    return dataSource;
  }
}

JPA配置:

代码语言:javascript
复制
package ...;
import ...;

@Configuration
@EnableJpaRepositories
@EnableTransactionManagement
public class JpaConfig {

  @Autowired
  private DataSource dataSource;

  @Value("${is.ddl.enabled}")
  private String isDDLenabled ;

  @Bean
  public EntityManagerFactory entityManagerFactory() {

    HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
    vendorAdapter.setGenerateDdl(Boolean.valueOf(isDDLenabled));

    LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
    factory.setJpaVendorAdapter(vendorAdapter);
    factory.setPackagesToScan("...");
    factory.setDataSource(dataSource);
    factory.setJpaDialect(new HibernateJpaDialect());
    factory.afterPropertiesSet();
    return factory.getObject();
  }


  @Bean
  public PlatformTransactionManager Here() {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setEntityManagerFactory(entityManagerFactory());
    return transactionManager;
  }
}

我和Jetty一起跑进来的。,当我运行它的前几次,它是好的,。但在8-15分之后,我得到了以下信息:

代码语言:javascript
复制
Failed startup of context ...
org.springframework.beans.factory.BeanCreationException:
...
org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.persistence.EntityManagerFactory]: Factory method 'entityManagerFactory' threw exception; nested exception is org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

在此之后,如果我试图运行该项目,则会得到相同的错误,直到在命令行中运行ipconfig /renew命令为止。在那之后,它又运行了8-15次,没有问题。

这里有人遇到过这样的事吗?ipconfig如何影响像这样的项目的运行?请帮帮忙。

EN

回答 1

Stack Overflow用户

发布于 2016-10-03 13:16:30

您使用的是org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter,您应该使用这个org.springframework.orm.jpa.vendor.HibernateJpaDialect

代码语言:javascript
复制
HibernateJpaDialect hibernateJpaDialect =new HibernateJpaDialect();

并将工厂对象设置如下:

代码语言:javascript
复制
factory.setJpaVendorAdapter(hibernateJpaDialect);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39829168

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档